← Back
vue

Pass all events up to the parent in vue

Suppose you create a custom button component. You can "re-emit" the click button to the parent:

<button @click="$emit('click', $event)">...</button>

But it's best to automatically pass all events up:

<template>
<button v-on="$listeners">

</button>
</template>

<script>
export default {
name: 'MyButton',
props: {
text: {
type: String,
optional: false,
},
},
}
</script>