Vue中使用prop传递方法并回调
父组件
<parent :before-close="wraperClose"></parent>
wraperClose(done) {
done()
},
子组件
<child @click="handleClose"></child>
props: {
beforeClose: {
type: Function,
},
},
methods: {
handleClose(e) {
this.$props.beforeClose(this.childFn);
},
childFn() {
console.log('子组件方法')
},
},