child.vue
<template>
<div>
<p>hello world</p>
<button @click = "go" class="btn btn-success">go</button>
</div>
</template>
<script lang="ts">
import Vue from 'vue'
import {defineComponent} from "vue"
export default defineComponent({
emits:['haha'],
setup(prop,context){
const methods = {
go(){
context.emit("haha")
}
}
return {
...methods
}
}
})
</script>
<style>
</style>
App.vue 使用就行了
————————————————
版权声明:本文为CSDN博主「爱生活,爱编程」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_15009739/article/details/111104813