I'm creating a small vue3 component and need to emit an event on a method call.
This is roughly how it looks :
export default {
emits: ['event'],
methods: {
myMethod () {
this.$emit('event') // throws Uncaught TypeError: this.$emit is not a function
}
},
mounted () {
this.$emit('event') //works perfectly fine
}
}
Can someone help me in finding what am I doing wrong ?
CodePudding user response:
Thanks, guys from comments, got me thinking in another way
I am just started learning Vue, and so the problem is pretty stupid
How I was calling the method from the parent component:
childComponent.methods.myMethod()
So I realized I was doing something wrong and after a couple of minutes of googling found the solution in the StackOverflow question