A very detailed explanation of the one-way data flow of vue parent-child components passing values (2)

Continuing from the previous chapter, the previous method still feels a bit cumbersome. Is there a simpler method? Have!

We add a .syncdecorator to the dialog-info tag in the outer parent component :
Insert picture description here
delete the @statusChangeHide directly:
Insert picture description here

The following change method is also deleted:
Insert picture description here

And remove it from the return object, then go back to the child component DialogInfo, delete the $emit statement in the previous handleClose callback function:
Insert picture description here
replace it with:

this.$emit("update:visible", false)

Insert picture description here
Note that there can be no spaces between "update:visible"!

Insert picture description here
Insert picture description here
This also achieves the desired effect

Guess you like

Origin blog.csdn.net/dyw3390199/article/details/114502873