vue is passed by two brothers. Why didn"t it work when component a was clicked for the first time? Do you need to go to the b component and then return the a component to pass the value?
onetwo
I created a js file
import Vue from "vue";
export default new Vue();
in the one component
<div>
A:
<span>{{elementValue}}</span>
<input type="button" value="" @click.stop.prevent="elementByValue($event)">
</div>
import Bus from "../assets/eventBus.js"
elementByValue: function () {
Bus.$emit("getTarget","123")
}
in the two component
import Bus from "../assets/eventBus.js"
Bus.$on("getTarget", target => {
console.log(target);
});
the first click in the one component has no effect. You have to go to the two component and then return to the one component. How to solve this situation?