<!-- 子组件 -->
<template><div class='container'><div>子组件</div><button @click="btn">按钮</button></div>
</template><script>export default {
name: 'Child',methods: {
btn() {
this.$emit('btn', false)}}}
</script>
<!-- 父组件 -->
<template><div class='container'><div>父组件</div><Child @btn="btn"></Child></div>
</template><script>import Child from '@/components/Child'export default {
components: {
Child },methods: {
btn() {
console.log('子组件')}}}
</script>