Open weijyewang opened 4 years ago
I agree on Wei Jye,
We should have a common method to handle multiple buttons. Here's another suggestion where you can pass parameter to event listener. Likewise in the emitter method here
instead having our event emitter calling multiple listeners like below:\ of this:
toParent(name) { this.$emit(name); this.toggle = false; },
I would suggest that we pass parameter like below :
toParent(name) { this.$emit('button-clicked',name); this.toggle = false; },
Take the example:
Says I have 5 buttons with alertMe event registered. I want to special handle each button to do something very specify depending on which button it is. Is there a way to know which button is triggering the event listener method via event object?
Maybe something like: