123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import { createApp } from 'vue'
- import necessaryInfoDialog from './components/necessaryInfoDialog.vue'
- import vuetify from '@/plugins/vuetify'
- const toastMessage = (type, option = {}) => {
- return new Promise((resolve, reject) => {
- const componentName = type === 'necessaryInfoDialog' ? necessaryInfoDialog : null
- const rootNode = document.createElement("div")
- document.querySelector('.v-application').appendChild(rootNode)
- const app = createApp(componentName, {
- // title,
- // text,
- option,
- cancel () {
- app.unmount()
- rootNode.remove()
- if (option.cancelCallback) {
- reject()
- }
- },
- sure () {
- app.unmount()
- rootNode.remove()
- resolve()
- },
- other () {
- app.unmount()
- rootNode.remove()
- resolve({ otherClick: true })
- }
- })
- app.use(vuetify)
- app.mount(rootNode)
- })
- }
- // 注册插件app.use()会自动执行install函数
- toastMessage.install = (app) => {
- app.config.globalProperties.Curtain = toastMessage
- }
- export default toastMessage
|