Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

352
Visualizações
DefineEmits in vue always return null

Recently, I have started using new Vue3 version of the code, however encountered few problems when using defineEmits.

Problem 1: defineEmits always returns null.

Problem 2: Receive Reference Error - "defineEmits not defined" when using it without importing from vue. Once importing from vue, error disappears. But, as per the standard, if we are using it inside setup api, no require to import it.

Can you please let me know if I am missing anything or doing something wrong?

Example of Problem 1:

<template>
   <div @click="onClose">This is example 1</div>
</template>
<script setup lang='ts'>
  import {defineEmits} from 'vue';
  const emit = defineEmits(['close']);//return value always null

  const onClose = conputed(()=> {
   emit('close'); // Due to null value in emit, this line throw exception
})

Example of Problem 2:

<template>
   <div @click="onClose">This is example 1</div>
</template>
<script setup lang='ts'>
  const emit = defineEmits(['close']);//error - ReferenceError - deinfeEmits not defined

  const onClose = conputed(()=> {
   emit('close'); 
})
</script>
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda