记录Vue用到了elementUI的el-table数组内对象发生改变页面没有重新渲染问题的解决

标题记录Vue用到了elementUI的el-table数组内对象发生改变页面没有重新渲染问题的解决

首先需要知道

1.当你利用索引直接设置一个项时,例如:vm.items[indexOfItem] = newValue
2.当你修改数组的长度时,例如:vm.items.length = newLength

例如:
data(){
    
    
	return (){
    
    
		tableData:[
			{
    
    
			"userName":'张三',
			"age":'18',
			"sex":'男'
			},
			{
    
    
			"userName":'李四',
			"age":'18',
			"sex":'男'
			}
		]
	}
}
this.tableData[0] = newValue
this.tableData.length = 3

为了解决以上问题,可以这样写

this.$set(this.tableData, 0, newValue)
this.tableData.splice(newLength)

おすすめ

転載: blog.csdn.net/weixin_45582733/article/details/104817629