子组件
<template>
<div>
{{name}}
<button @click="butTap1">butTap1</button>
<button @click="butTap2">butTap1</button>
</div>
</template>
<script setup lang="ts">
const emit = defineEmits(['butTap11', 'butTap21'])
const butTap1=()=>{
emit('butTap11','sb')
}
const butTap2=()=>{
emit('butTap21','lc')
}
withDefaults(defineProps<Props>(),{
name:'lc'
})
type Props={
name:string
}
</script>
父组件
<Tc name='sblc' @butTap11="butTap11" @butTap21="butTap21"></Tc>
import Tc from './testComponent.vue'
const butTap11=(e)=>{
console.log(e)
}
const butTap21=(e)=>{
console.log(e)
}