跳到主内容

如何在 vue3 中从 `setup` 方法中`emit` 事件?

· 1分钟阅读

setup 函数有两个参数,第一个是 props , 第二个是 context 暴露了三个组件属性 attrsslotsemit

可以通过 context 来 emit 事件:

export default {
setup(props, context) {
context.emit("event");
},
};

阅读更多关于 context 的细节