Search code examples
javascriptfrontendvuejs3quasar-frameworkeventemitter

I got this error " this.$emit is not a function " I'm using vue 3 and quasar framework


function irAlLink(link) {
  if (linkAbierto.value.includes(link)) {
    this.$emit('linkClickeado', link)
    router.replace('/main')
  } else {
    this.$emit('linkClickeado', link)
    router.replace(link)
  }
}

I'm trying to giving the link to my other component:

<EssentialLink v-for="link in links2" :key="link.text" v-bind="link" @linkClickeado="agregarLink()" :linkAbierto="linkAbierto"/>

Solution

  • Within vue3 it isn't possible to access this. within the setup script.

    Please check this post:

    How to `emit` event out of `setup` method in vue3?