elementUI表格组件中懒加载子级即时更新的问题(添加、删除、修改)

遇到的问题:elementUI表格组件中,更新数据后,懒加载的数据没有即时更新。

前端代码:

<el-table
          :data="dataList"
          ref="dataTable"
          style=" 100%;"
          row-key="id"
          v-loading="dataListLoading"
          lazy
          :load="load"
          :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
</el-table>

对表格的子列进行添加操作后:

  if (val !== undefined) {
        let nodeMapVal = this.$refs.dataTable.store.states.lazyTreeNodeMap[val]
        if (nodeMapVal !== undefined && typeof nodeMapVal === 'object') {
          if (nodeMapVal.length > 0) {
            this.$http.get('URL路径?id=' + val).then(({ data: res }) => {
              this.$refs.dataTable.store.states.lazyTreeNodeMap[val] = res.data
              this.query()
          })
        }
     }
  }

  

其中val即为id。本质上是对element表格的懒加载树中的子节点进行了手动更新。

原文地址:https://www.cnblogs.com/jeacy/p/15739392.html