Vue数据发生变化,视图层不更新

先是在数据中添加了一个字段,结果发现每次更改字段值,值发生变化,但是视图层却不更新

this.AllRoleList.forEach(function(item,index){

                         item["check"]=false
					})

其实发现这样写不会被监听到 应该使用set方法赋值

this.AllRoleList.forEach(function(item,index){
                           Vue.set(item,0,{"check":false})
                         
					})
完美解决

猜你喜欢

转载自blog.csdn.net/qq_29819449/article/details/80769265