计算属性怎么传参?
<ul>
<li v-for="item in goods" :style="goodsType" v-text="item.name"></li>
</ul>
data: {
goods: [{
id: 2,
type: 3,
name: '薯片'
},{
id: 3,
type: 5,
name: '冰红茶'
}]
},
computed: {
goodsType: function(type){
switch (type) {
case 3:
return "color: #ff9900"
break;
case 5:
return "color: #00BC0C"
break;
}
}
}
传不了参的,你可以写成methods