shortEmits
稳定性:
稳定简化 emits 的定义。
在 Vue >= 3.3 中,此功能将默认关闭。
| 特性 | 功能 |
|---|---|
| Vue 3 | ✅ |
| Vue 2 | ✅ |
| TypeScript | ✅ |
基本用法
使用 ShortEmits 或简写为 SE,可以使用元组或方法定义。
vue
<script setup lang="ts">
const emits = defineEmits<{
// 元组
'update:modelValue': [val: string]
// 方法
update(val: string): void
}>()
</script>Difference with Official Version
- function style of declaration is not supported by official version.