html isLeaf为true不显示展开图标,data是已获取的树形结构,遍历需要懒加载将isLeaf设为false
<el-tree-select
v-model="queryParams.treeValue"
:lazy="queryParams.type === 'user'"
:load="load"
:data="treeList"
:check-strictly="true"
:props="{
label: 'name',
children: 'children',
value: 'id',
isLeaf: 'isLeaf',
}"
js
const load = async (node, resolve) => {
if (node.data && node.data.isLeaf === false) {
if (node.data.type === "community") {
const url = ''
let buildings = await proxy.$get(url, { communityId: node.data.id });
let arr = [];
buildings.data.forEach((element) => {
arr.push({
name: element.name,
id: element.id,
type: "building",
isLeaf: false,
});
});
return resolve(arr);
} else if (node.data.type === "building") {
const url = ''
let users = await proxy.$get(url, { buildingId: node.data.id });
let arr = [];
users.rows.forEach((element) => {
arr.push({
name: element.name,
id: element.id,
type: "user",
isLeaf: true,
});
});
return resolve(arr);
} else {
return resolve([]);
}
} else {
if (node.data && node.data.children) {
return resolve(node.data.children);
} else {
return resolve([]);
}
}
};