<el-tree
ref="treeRef"
style="max-width: 600px"
class="filter-tree"
:data="treeData"
:props="defaultProps"
default-expand-all
:filter-node-method="filterNode"
node-key="id"
@node-click="handleNodeClick"
/>
const treeRef = ref<InstanceType<typeof ElTree>>();
const handleDelete = (ids: string) => {
ElMessageBox.confirm("确定删除吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
deleteApi(ids).then(async () => {
// 刷新树
await getTreeData();
//删除时,树的数据改变了,但是树不刷新,需要手动调用树的remove方法
if (treeRef.value) {
treeRef.value.remove(currentTreeItem);
}
ElMessage.success("操作成功");
});
});
};