vue 数组内对象修改属性页面不渲染问题

vue 数组内对象修改属性页面不渲染问题

数据:

let _arr = [{id:1},{id:2},...]
@click=function(k){
    _arr[k].id =m
}

这时候页面是不会渲染新的数据


解决方法:可以使用vue.$set()

@click=function(k){
    this.$set( _arr[k],'id','m')
}
具
如果还是不能实现页面渲染请用终极大招:
$forceUpdate()

引用块内容

体参考官网文档 https://cn.vuejs.org/v2/api/#vm-set

猜你喜欢

转载自blog.csdn.net/bule_chen/article/details/78590705