Child component A passes the value to the parent component by clicking the button event, and then passes the value from the parent component to child component B. Why does child component B receive the value only when the button is clicked for the first time, and then multiple button clicks do not work. If you refresh, you can only receive the value for the first time. The
code is as follows:
Sub-component A button Click to pass value event:
goIndex () {
this.$emit ("gogo","a");
}
parent component receiving code:
HTML:
< componentsA @ gogo = "button" > child component A < / componentsA >
< componentsB: child-tab = "isAddedTab" > child component B < / componentsB >
JS:
export default {
data () {
return {
isAddedTab:""
}
},
components: {
moneyDetails,
settings
},
methods: {
button(e){
console.log(e);
this.isAddedTab = e;
},
}
}
subcomponent B received value:
props: ["childTab"],
watch: {
childTab(v){
console.log(v);//vA
}
},