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