父组件内容:
<template>
<div>
<info-wnd ref="infoWnd" @parentClick="wndClick"></info-wnd>
</div>
</template>
<script>
import infoWnd from './info-wnd';
export default {
data() {
return {
}
},
components: { infoWnd },
methods: {
wndClick() {
console.log('这是父组件的方法');
}
}
}
</script>
子组件Info-wnd.vue组件内容:
<template>
<div @click="divClick">
<span>这是子组件</span>
</div>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
divClick() {
this.$emit('parentClick'); //调用父组件的方法
}
}
}
</script>
来源:https://www.cnblogs.com/minozMin/p/9830015.html