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


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

 

前端代码:

<el-table
          :data="dataList"
          ref="dataTable"
          style="width: 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表格的懒加载树中的子节点进行了手动更新。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM