计算 单个数据 数组数据

单个数据

      computed: {
            sum: function () {
                  return parseFloat(this.count * this.price).toFixed(2);
             },
      },

数组数据

      computed:{
            total:function(){
                let total = 0;
                this.list.forEach((item)=>{
                    if(item.price && item.price > 0){
                        total += parseFloat(item.price );
                    }
                })
                return total;
            },
        },
posted @ 2020-11-27 15:43  JaneLifeVlog  阅读(77)  评论(0)    收藏  举报