VUE + Element UI 树形 table 懒加载问题
这两天项目用到了 element ui 的树形结构做菜单,使用了懒加载机制,导致新增和删除菜单时无法正确加载菜单问题,网上文章找了一大圈,全是同样解决方法,记录一下投机取巧的解决方案:
直接上代码:
<template>
<el-table:data="dataList"
row-key="id"
lazy
:load="load"
node-key="id"
ref="tree"
:expand-on-click-node="true"
:tree-props="{children:'children', hasChildren:'hasChildren'}"
>
<!-- 列表主体 -->
<el-table-column>
<template slot-scope="scope">
<el-button @click="createChildren(scope.row,true)">添加下级
</el-button>
<el-button @click="deleteVerify(scope.row.id)">删除
</el-button>
</template>
</el-table-column>
</el-table>
</template>
<script>
export default {
data() {
return {
createChild: '',
treeNodeMap: new Map