this.shopCart是接口拿到的购物车对象 遍历对象中的num
goodsNum() {
let num = 0;
Object.values(this.shopCart).forEach((goods, index) => {
num += Number(goods.num);
});
if (num > 0) {
return num;
}
},
网友评论