父组件Father.vue
<template>
<Child @func="handle" />
</template>
<script setup>
import Child from '@/views/Child.vue';
const handle = () => {
console.log('父组件的方法')
}
</script>
子组件Child.vue
<template>
<view>子组件</view>
<button @click="test">调用父组件的方法</button>
</template>
<script setup>
const $emit = defineEmits(["func"])
const test= () => {
$emit("func", "click");
}
</script>