vue3.x emit 用法
child.vue<template><div><p>hello world</p><button @click = "go" class="btn btn-success">go</button></div></template><script lang="ts">import Vue f
·
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 使用就行了
更多推荐
已为社区贡献5条内容
所有评论(0)