Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

350
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!