Avoid mutating a prop directly since the value will be overwritten whenever...

1. Problem: The parent component passes the value to the child component, and the child component uses the value passed by the parent component, and the following exception occurs

Insert picture description here
2. Solution: The child component cannot directly use the value passed by the parent component. The passed value needs to be redefined, and then the redefined value can be used normally.

3. Specific operation: use watch to monitor the change of the value passed by the parent component, and then reassign the changed value to the new value defined in data, and the child component uses the new value to operate.

a. Define a new value in the data of the child component
Insert picture description here
b. Monitor the change of the value passed by the parent component and re-assign it

Insert picture description here
c. Sub-components use new variables to operate
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_43234632/article/details/111181894