v-for 数组 ,改变数量的时候,数据明明已经改变,但是页面渲染不出来
<view class="class-item" :id="'item' + index" v-for="(item1 , index) in goodsList" :key="index">
<view class="mt10">
<view class="flex ft12 alcenter">
<view>
<image v-if="item1.icon != ''" class="item-menu-img wt80" :src="item1.goodsImg" mode="widthFix"></image>
</view>
<view class="pl10">
<view>{{item1.goodsName}}</view>
<view class="ft10 gray9 mtb10">可邮全国</view>
<view class="flex alcenter">
<view class="red2">¥{{item1.goodsPrice}}</view>
<view class="flex ft10 alcenter">
<view class="gray9">已售</view>
<view class="mlr5 gray9">1万+</view>
<view class="flex ml5 jsend alcenter">
<view class="iconfont icon-quxiao green" @click="reduce(index,item1)"></view>
<view class="bgGray"><input type="number" disabled="true" v-model="item1.num" :value="item1.num" class="wt25 gray3 tc"/></view>
<view class="iconfont icon-add-circle green" @click="plus(index,item1)"></view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
JS
reduce(index,obj){
if(obj.num < 1){
obj.num = 0;
}else{
obj.num = obj.num - 1;
}
this.goodsList.splice(index,1,obj);
this.gettotal()
},
plus(index,obj){
obj.num = obj.num + 1;
this.goodsList.splice(index,1,obj);
this.gettotal()
},
网友评论