Skip to content

shortEmits

Stability: stable

Simplify the definition of emits.

For Vue >= 3.3, this feature will be turned off by default.

FeaturesSupported
Vue 3
Vue 2
TypeScript

Basic Usage

vue
<script setup lang="ts">
import { 
defineEmits
} from 'unplugin-vue-macros/macros'
const
emits
=
defineEmits
<{
// tuple 'update:modelValue': [
val
: string]
// function
update
: (
val
: string) => void
}>() </script>

Using type ShortEmits or for short SE.

vue
<script setup lang="ts">
const 
emits
=
defineEmits
<
SE
<{
// tuple 'update:modelValue': [
val
: string]
// function
update
: (
val
: string) => void
}> >() </script>

Difference with Official Version

  • function style of declaration is not supported by official version.

Contributors

The avatar of contributor named as renovate[bot] renovate[bot]
The avatar of contributor named as gaokefei gaokefei
The avatar of contributor named as zhiyuanzmj zhiyuanzmj
The avatar of contributor named as Kevin Deng Kevin Deng

Changelog