// Child.vue
<template>
<view>
<button @click="childMethod">我是子组件</button>
</view>
</template>
<script>
export default {
name: "Child",
props: {
fatherMethod: {
type: Function,
require: true,
default: null,
},
},
methods: {
childMethod() {
console.log(
"我是子组件的方法,我在子组件中通过 props 的方式调用了父组件的方法"
);
this.fatherMethod();
},
},
};
</script>
<style scoped>
</style>
08-15