Last week, when using an elementUI table, I found that every time I click on the checkbox of the table, the page will be stuck for close to two seconds, so I used vue’s devtools to record where the operation time is consumed each time. It was found that the main reason is that although the elementUI table provides tree data and lazy loading functions, although the child nodes are not expanded, they have already been rendered.
Therefore, the elementUI table provides the function of lazy loading, but this lazy loading function is problematic, because the lazy loading function will only be called once, and no matter how the data is changed in the future, the sub-node will not change.
After analyzing the source code of vue and elementUI, I found the reason and fixed it appropriately. I will record it here.
The main purpose of the refreshLazyRows () function is to update’this. $refs.listResourceTableRef.store states.lazyTreeNodeMap ', which is the object that the child node listens to
As for why the existing mapping should be deleted first, it is because if the old one is not deleted, a new mapping will be added directly, and we will add a new node as the parent node, which will cause the node to be nested layer by layer, and It will cause elementUI to report a duplicate key error.