使用懒加载解决子节点增删后,不刷新新节点数据问题
<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
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/279322.html