I got a console error when I tried to list custom event in the component's emits option like this:
PARENT
<Btn
event-name="toggleSideMenu"
@toggle-side-menu="toggleHandler">
toggle
</Btn>
CHILD
<template>
<button @click="handleClick">
<slot></slot>
</button>
</template>
export default {
props: {
eventName: {
type: String,
default: ''
}
},
emits: [this.eventName], // Uncaught TypeError: Cannot read property 'eventName' of undefined
methods: {
handleClick() {
this.$emit(this.eventName)
}
}
}
How is the correct way to get this thing to work?