父组件Father.vue
<template>
<Child :parentMethod="parentMethod" />
</template>
<script setup>
import { defineComponent } from 'vue';
import Child from './Child.vue';
const parentMethod = () => {
console.log('这是父页面的一个方法');
};
</script>
子组件Child.vue
<template>
<button @click="parentMethod">点击调用父组件中的方法</button>
</template>
<script setup>
import { defineProps } from 'vue';
const props = defineProps({
parentMethod: Function
});
</script>