Element树形懒加载表格,数据刷新时刷新列表(触发懒加载)
作者:互联网
使用懒加载解决子节点增删后,不刷新新节点数据问题
<el-table
:load="load"
ref='myTable'
data () {
return {
maps: new Map()
}
}
methods: {
load (row, treeNode, resolve) {
// 存在map里
this.maps.set(row.id, {row, treeNode, resolve})
}
// 当数据改变时需要重新执行懒加载,刷新列表
方法: this.$set(this.$refs.myTable.store.states.lazyTreeNodeMap, parentId, result.data)
this.reset(this.$refs.myTable.store.states.lazyTreeNodeMap, this.maps, row.id)
reset (lazyTreeNodeMap, maps, parentId) {
let {row, treeNode, resolve} = maps.get(parentId)
** this.$set(lazyTreeNodeMap, parentId, [])**
// 重新调用懒加载方法
this.load(row, treeNode, resolve)
}
}
参考文献: https://blog.csdn.net/m0_46627730/article/details/106139925
https://www.cnblogs.com/spll/p/16063965.html
标签:load,treeNode,parentId,Element,maps,刷新,加载,row 来源: https://www.cnblogs.com/zw100655/p/16558438.html