xuanvalue: -1, data里定义
在可编辑表格里加上这行代码
this.selectRow(params.index);
三元表达式 动态绑定保存的名字
{
title: "操作",
key: "action",
render: (h, params) => {
return this.$tableAction(h, [
{
title: params.index == this.xuanvalue ? "保存" : "",
action: () => {
this.saveRow(params.row);
},
},
]);
},
},
方法:
//获取当前点击索引
selectRow(e) {
console.log(e);
this.xuanvalue = e;
},
//保存
saveRow(row) {
this.xuanvalue = -1;
}
},