美文网首页
uniapp v-for数据改变后,页面没渲染的问题

uniapp v-for数据改变后,页面没渲染的问题

作者: 配角_2763 | 来源:发表于2023-09-03 01:23 被阅读0次
    微信截图_20230904011957.png

    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()
    },
    

    相关文章

      网友评论

          本文标题:uniapp v-for数据改变后,页面没渲染的问题

          本文链接:https://www.haomeiwen.com/subject/fjjfvdtx.html