Vue2 全局-Vue.set更新vue数据
代码:{{ name }} --- {{ price }} --- {{ count }}减少function reduceOne() {Vue.set(cartData, 'count', cartData.count-1);}var cartData={name:"T-shirt
·
代码:
<div id="shoppingCart">
<ul>
<li>{{ name }} --- {{ price }} --- {{ count }}</li>
</ul>
</div>
<button οnclick="reduceOne()">减少</button>
<script>
function reduceOne() {
Vue.set(cartData, 'count', cartData.count-1);
}
var cartData={
name:"T-shirt",
price:"$26.80",
count:20
};
var cart=new Vue({
el:"#shoppingCart",
data:cartData
});
</script>
更多推荐
已为社区贡献8条内容
所有评论(0)