在组件中emit使用方法:
父组件:
<Dialog @change="change"/>
setup(){
const change=(value)=>{
}
}
子组件使用:
setup(props, { emit }) {
const close = ()=>{
emit("change")
}
return{
close
}
}
或者
setup(props, context){
const { emit } = context;
const close = ()=>{
emit("change")
}
return{
close
}
}
或者
import {getCurrentInstance} from "vue"
setup(){
const {global} = getCurrentInstance();
const close = ()=>{
global.$emit('change')
}
return{
close
}
}