方法1:el-table使用key,在值发生变化时,改变key值
<el-table :data="goodsList" :key="isUpdate">
在数据更新的地方后面加上如下 this.isUpdate = !this.idUpdate
方法2:使用this.$set
1、在定义的时候就写入属性(此时只要在下拉框选择,那么显示就会实时更新),不显示,一般table数据都是后台请求回来的,或者是添加功能的时候,跟table的各列绑定,不会提前定义
goodList:[
{
id:111
}
]
2、在方法内使用this.$set()进行赋值(比较适合于在方法内,需要对页面的值重新赋值)
changeAllTemplate(){
this.goodsList.map(item=>{
this.$set(item, 'tpl_id', this.current_tpl_object.id)
this.$set(item, 'tpl_name', this.current_tpl_object.tpl_name)
})
},