I created this selection field. I want to reflect the selected fruits from the SelectAll component on its parent component, so I created a component event (@Emit("fruitsSelected")) for it -- it shall return the selectedFruits string array to the the Parent.vue.
The code works fine if fruits are selected one by one. But, $emit doesn't fire up if the Select All button is used in the drop-down. I'm not sure why. Any help? Thank you!
tao's answer using the
@Watchdecorator is correct but just wanted to add why your original code didn't work, and that is because yourtoggle()method was not tied to any emit. Only yourreturnSelectedFruits()was emitting anything. This should also work: