父组件
<template>
<div>
<Menu @onclick="getList" @onclick2="getList2" />
</div>
</template>
<script setup lang="ts">
import {reactive ,ref} from 'vue'
const getList=(list:number[])=>{
console.log(list)
}
const getList2=(list:number[])=>{
console.log(list)
}
</script>
<style scoped>
</style>
子组件
<template>
<div class="menu">
<div class="">
<button @click="clickTap">派发1</button>
<button @click="clickTap2">派发2</button>
</div>
</div>
</template>
<script setup lang="ts">
import {reactive, defineEmits} from 'vue';
const list=reactive<number[]>([6,6,6,6])//number类型的数组值为[6,6,6,6]
const list2=reactive<string>('11')
const emit=defineEmits(['onclick','onclick2']);
const clickTap=()=>{
emit('onclick',list)
}
const clickTap2=()=>{
emit('onclick2',list2)
}
</script>