VUE rookie, wrote a BUS to pass parameters. There is no problem between sibling components of the same code. If used on parent-child components, the parent component cannot get the value passed by $on. There is no problem with the reference of BUS. I have tried to replace it with this, but I use a multi-check box to get the value using the monitor. All the people on the Internet use click events to get the value, so I don"t understand the usage of this this.
this is the parent component code:
created () {
Bus.$on("checkList", function(params) {
params.forEach(function (p) {
console.log(p)
});
});
}
this is the subcomponent code:
watch: {
checkList (val) {
Bus.$emit("checkList", val);
}
},
the running result of the peer component. Clicking multiple selections will traverse all the values in the checkbox: