Turn to a vue component data reset problem

enter a page
has such a structure
parent component > child component > grandchild component, each component has its own data data. Now I want to reset the data of grandchild component by closing child component. What is the implementation method?

Mar.11,2021

abstracting the problem is actually implementing the parent component to change the child component data. The data that needs to be changed is bound to a data in the parent component through v-bind, and the parent component passes the data to the child component. When the child component observes the data from the parent component and changes itself, when it needs to be reproduced, the parent component assigns the initial value to the bound data.


if the data is all derived from the parent component, the parent component passes the reset method to the child component through props, which is called when the child component is beforeDestroy. Otherwise, the data that is automatically reset is created after the component is destroyed.

Menu