vue3的defineEmitsi型別宣告註解

light丶發表於2024-06-19
//格式:defineEmits<{(e:事件名,val:資料型別):void}>()
const emit = defineEmits<{
    (e: 'get-msg', val: string): void,
    (e: 'say-hello', num: number): void
}>()

const fn = () => {
    emit('get-msg', '你好')
}
const fns = () => {
    emit('say-hello', 11)
}

相關文章