import messageBox from './src/index.vue' import { createVNode, render } from 'vue' let mountNode: HTMLElement | null interface Ioptions { title: string message: string } const $messageBox = (options?: Ioptions) => { return new Promise((resolve, reject) => { function destoryNode() { if (mountNode) { render(null, mountNode) } } const app = createVNode(messageBox, { ...options, confirm: () => { resolve() app.component?.exposed?.ok() destoryNode() }, cancel() { reject() app.component?.exposed?.ok() destoryNode() } }) if (!mountNode) { mountNode = document.createElement('div') document.body.appendChild(mountNode) } render(app, mountNode) }) } export default $messageBox