vue中出现数据更新了视图没更新的情况

比如我们视图中是动态绑定了类名

<span class="tubiao" :class="{'activationtu':items.icontype}" @click="CouponCilk(inx,ix,items.icontype)">

数据中的值

多维数组

如果只是改变icontype去切换动态类名的话,我们则需要使用数组的splice方法去替换如一下代码:

CouponCilk(finx,sinx,type){
           // finx=>父级索引,sinx子级索引
           this.OrdergoodsList[finx].coupons.forEach((item,index)=>{
               item.icontype = false
           })
            if(!type){
                    this.OrdergoodsList[finx].coupons[sinx].icontype = true
            }else{   
                this.OrdergoodsList[finx].coupons[sinx].icontype = false
            }
            // 修改最顶级的数组子项
           this.OrdergoodsList.splice(finx,1,this.OrdergoodsList[finx])  
        },

猜你喜欢

转载自blog.csdn.net/Hgh_1997/article/details/85260691