
正文
vue 子组件 $emit方法 调用父组件方法
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
$emit方法
父组件
<template>
<div>
<child @callFather="activeSon"></child>
</div>
</template>
<script>
import child from '@/components/child';
export default {
components: {
child
},
methods: {
fatherMethod() {
console.log('father组件');
},
activeSon(){
this.fatherMethod()
}
}
}
</script>
子组件
<template>
<div @click="activeBtn"> </div>
</template>
<script>
export default {
methods: {
activeBtn() {
this.$emit("callFather")
}
}
}
</script>





