prop传来的对象都要用this获取 !
计算属性中的方法调用其他计算属性时也用this
computed:{
totalPrice(){
let total = 0;
for(let i=0;i<this.selectFoods.length;i++){
total += this.selectFoods[i].price * this.selectFoods[i].count
}
return total
},
totalCount(){
let count = 0;
for(let i=0;i<this.selectFoods.length;i++){
count += this.selectFoods[i].count
}
return count
},
payClass(){
if(this.totalPrice < this.minPrice){
return 'not-enough'
}
求自己别眼瞎了