遇到的問題: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表格的懶加載樹中的子節點進行了手動更新。
