Recently delving into the world of vue js, I've been tinkering around with a recursive tree example inspired by the official example found here.
While the original example starts with treedata containing a single root and multiple children, my goal was to expand this to include multiple root elements, as showcased in this example.
In my own example, I observed that the beforeUpdate
method is triggered twice for every component click. Even when attempting to directly add elements into children
, the beforeUpdate
is still called twice. Conversely, in the official recursive example, this only happens once (verified using vue-devtools). I'm puzzled by this behavior and would appreciate any insights on why it occurs.
Could this be linked to using v-for
in li
instead of the actual component name?
UPDATE:
I included a datetime
to track which elements are being re-rendered, and it appears that in my example, all children are re-rendered, as evidenced by the time displayed on the component.