具体代码
html
<el-tree
style="width: 100%"
ref="treeRef"
:data="roleTreedata"
show-checkbox
:expand-on-click-node="false"
:check-strictly="!isParentchildLinkage"
:props="defaultProps"
node-key="id"
/>
js
import { ElTree } from "element-plus";
const treeRef = ref<InstanceType<typeof ElTree>>();
const expandBtn = (e: boolean) => {
const allNodes = treeRef.value!.store._getAllNodes();
allNodes.forEach((item, index) => {
item.expanded = e;
});
};