In Vue.js, how can I emit multiple value from child to parent while parent's v-on pass another parameter?
Define a handler that accepts the multiple parameters from the event and passes them along to the change method in addition to your static parameter.
<button-counter v-on:change="(...args)=>this.change(1234,...args)"></button-counter>
Alternatively
<button-counter v-on:change="(...args)=>this.change([1234,...args])"></button-counter>
And change your method to
change: function (args) {
this.args = args
console.log(args)
}
I would do this:
<button-counter v-on:change="change(1, ...arguments)">
You can use destructuring syntax
this.$emit('change', { x:'v1', y:'v2', z: 'v3' })
And you can access these values like so
<button-counter @change="change"></button-counter>
methods: { change({x, y, z}) { .... } }