首先html中调用el-table组件需要注意
在这里插入代码片
<el-table :data="tableData" v-loading="loading" row-key="id" ref="table"
:lazy="true"
:load="loads"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
@expand-change="handleExpandChange" 。。。。
其次在data()中放入属性
copyData: [], //赋值拷贝数据
maps: new Map(), //用于存储 子节点懒加载的数据
copymaps: new Map(),
doSelect: {
id: null, title: "" }, //子节点懒加载对应的节点
meth() 中
getList() {
this.loading = true;
// 执行查询
getPage(this.queryParams).then((response) => {
this.list = response.data;
this.copyData = JSON.parse(JSON.stringify(response.data));
this.tableData = this.list;
this.tableData.map((item) => {
item.hasChildren = item.children && item.children.length > 0;
item.idList = [item.id];
item.children = null;
return item;
});
console.log(this.tableData);
this.$nextTick(() => {
this.refreshRow();
});
this.loading = false;
});
},
```kotlin
loads(tree, treeNode, resolve) {
const pid = tree.<