vue el-table 嵌套 input 数据更新问题

 

el-table 加key更新视图

el-table 加上 key
:key="num" //用于视图更新数据

 

el-table 嵌套了 input 输入框,绑定了 table 列表的数据的时候,更新不能用 v-model,得用 :value 去更新

:value 更新视图确保能拿到数据, @input 方法更新视图, 得用 箭头函数去强制更新

:value="scope.row.lowestCredits" @input="val=>settingInput('lowestCredits', scope.$index, val)"

 

// 这里的table 是你绑定的列表数组,用 index 和 key 分别定位 和 辨别类型( PS: 唯一 ),最后,把 带在 table 上的key 去更新就可以达到更新视图的效果

//改变table表格input数据
        settingInput(key, index,value){
            this.tableData[index][key] = value;
            this.$set(this, 'tableData', this.tableData)
            this.num ++
            // this.$set( this.tableData[index],value )
        },

 

posted @ 2022-05-30 18:32  薛定谔_猫  阅读(2176)  评论(0)    收藏  举报