Why does the swipe component of mint-ui rely on the order in which $children traverses the subcomponents?

after learning the code of the swipe component of mint-ui, you see the following code snippet:

clipboard.png

Code link

as mentioned earlier in the vue.js document, accessing child components through $children does not guarantee order. But the code here in the swipe component seems to rely directly on the order in which the child components are traversed by $children . I feel a little confused here.

I hope some students who are familiar with vue.js or mint-ui can help explain it. I appreciate it!

Nov.08,2021

< H1 > about $children does not guarantee the order < / H1 > The $children property of the

vue instance always saves the child component instances in the order in which was created , rather than the order in which the child component instances are in the entire component tree.

if the subcomponent instance does not change its position in the component tree due to changes in data after it is created, its order in $children can reflect its order in the component tree.

if subcomponent instances change their order in the component tree due to data changes, this change will not be reflected in $children , because $children always saves subcomponent instances in the order in which they were created.

< H1 > about the swipe component of mint-ui < / H1 > The

swipe component implements the effect of the rotation graph. If the order of the data used to generate the broadcast items does not change, and the new rotation item data is appended from the tail, in this case, $children can correctly reflect the real order of the sub-component instances in the component tree.

Menu