实现用vue3封装一个弹框组件的方法
引入子组件
<qhyaDaylog ref="qhyaDaylogCom"></qhyaDaylog>
import qhyaDaylog from './components/xzya.vue';
需要使用vue3抛出的方法
const qhyaDaylogCom = ref(null);
const changeActive = () => {
if (qhyaDaylogCom.value) {
qhyaDaylogCom.value.handleQHYAShowFlagClick();
}
子组件
<n-modal v-model:show="QHYAShowFlag">
</n-modal>
import { defineExpose } from 'vue';
//事件
const handleQHYAShowFlagClick = () => {
QHYAShowFlag.value = true;
};
defineExpose({ handleQHYAShowFlagClick });