方法一:
//子组件
setup(props,context) {
toParent() {
context.emit('msg',111)
}
}
父组件
<child @msg="childmsg"></child>
childmsg(e){
console.log(ee)
}
方法二:
//子组件
import {
getCurrentInstance,
} from "vue";
setup(props) {
const { proxy } = getCurrentInstance();
toParent() {
proxy.$emit('msg',111)
}
}
父组件
<child @msg="childmsg"></child>
childmsg(e){
console.log(ee)
}