Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

351
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda