{{totalCount}}
data:
shopList:[
{price:5,num:5},
{price:6,num:6}
]
computed:{
totalCount(){
let total = 0
shopList.forEach(function(ele,index){
total += ele.price * ele.num
})
return total
}
}
totalCount为html中的data值,不需在data中声明,不是方法,实时更新。totalCount为61