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>