On the problem of vue passing value v-show

</div>

in a child component, there is a div, v-show that controls how the div is shown and hidden, how to pass the isShow to the parent component, and then controls the value of the isShow in the parent component to show and hide the div.

Mar.02,2021

take a good look at the documentation. How do you use emit, and props


many
parent components define a value isShow
child component isShowChildren: this.$parent.isShow

=
the parent component invokes the child component method
child component to control the value true or false of isShow


since it is controlled in the parent component, you can define the isShow, directly in the parent component and pass it to the child component through props


vue parent-child component communication ,


wrote you the online demo : https://jsfiddle.net/luozz/f6.

of one of the methods.
I hope it will be helpful to you!

1.
1) bind in the child build of the parent component
: message = "this is the passed value"
2) define the passed value in the child build

props:['message']  // 
3)this.

2.
defines the passed value
this.$emit ('childOne', 0)
this.$emit (' passed name', passed value)
in the child component
< v-login @ childOne= "thisChild" > < / v-login >

to note the child build binding event in the parent component.

when defining the event, the type is the value passed from the child component
thisChild: function (type) {
this.isShow = type
},

Menu