elementui el-table表格展开行,对当前展开行内容进行修改删除操作时,要当前行默认展开
方式一 上代码
<el-table
v-loading="listLoading"
:data="list"
:row-key="getRowKeys"
border
style="width: 100%"
:expand-row-keys="expandednewarr"
>
根据情况使用唯一值
getRowKeys(row) {
return row.user.uid;
},
接口中
deleteItem(item, i) {
const data = {
id: [item.cart_id],
};
batchDelete(data).then((res) => {
this.$message({
message: "删除成功",
type: "success",
});
this.getList();
this.expandednewarr.push(this.list[i].user.uid);
});
},
方式二 上代码
<el-table
v-loading="listLoading"
:data="list"
:row-key="getRowKeys"
border
style="width: 100%"
@expand-change="expandChange"
:expand-row-keys="expandednewarr"
>
根据情况使用唯一值
getRowKeys(row) {
return row.user.uid;
},
change事件改变
expandCHange(row, expanded) {
this.expandednewarr = [];
expanded.map((item) => this.expandednewarr.push(item.id));
},