效果图:
实现代码:
index.ts:
import NewFolderDialog from './NewFolder.vue';
import { h, render, App } from 'vue';
const createMount = (app: App, opt: any) => {
const mountNode = document.createElement('div');
document.body.appendChild(mountNode);
const vnode = h(NewFolderDialog, {
...opt,
remove() {
document.body.removeChild(mountNode);
},
});
// 将vnode的上下文指向当前app的上下文
vnode.appContext = app._context;
render(vnode, mountNode);
};
const Modal = {
install(app: App) {
app.config.globalProperties.$newFolderDialog = {
show: (options = {} as any