Vue $nextTick method usage scenarios

 

Requirement: use vue to encapsulate ztree, because ztree needs to determine the DOM node id and data, execute the initialization method to complete the tree display of ztree, in order to make the component trees introduced by vue not affected by each other (the objects are independent of each other), So ztreeid is generated using timestamp + random number .

 

Problem: Because it is a variable, it is found that after sending the ajax request data back, the DOM tree has not been rendered (there is no dynamically generated ID), resulting in the tree not being generated.

 

Solution:

Modify the value of treeId and use the $nextTick function to ensure that the ajax request is sent after the dom tree changes , so that there will be no embarrassing phenomenon that there is no corresponding ID node in the data when the initialization method is executed.

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326393478&siteId=291194637