shortEmits
Stability:
stable
Simplify the definition of emits.
For Vue >= 3.3, this feature will be turned off by default.
Features | Supported |
---|---|
Vue 3 | ✅ |
Vue 2 | ✅ |
TypeScript | ✅ |
Basic Usage
Using type ShortEmits
or for short SE
.
vue
<script setup lang="ts">
const emits = defineEmits<
// `ShortEmits` or for short `SE`
SE<{
// tuple
'update:modelValue': [val: string]
// function
update(val: string): void
}>
>()
</script>
Difference with Official Version
ShortEmits
orSE
is no longer needed in official version. Use it directly.- function style of declaration is not supported by official version.