弹窗的extend写法

import Vue from 'vue'
import router from '@/routes.js'
import {
    sweetStore
} from '@ime/ime-core'
const files = require.context('./', false, /\.vue$/)
// 获取文件夹文件
const getFolderFiles = (nameReg) => {
    let map = {}
    for (const key of files.keys()) {
        let resKey = key.replace(nameReg, (match, param) => param)
        map[resKey] = files(key).default || files(key)
    }
    return map
}
const modules = getFolderFiles(/\.\/(\S*?)\.vue$/)

let Alert = {}
for (const key in modules) {
    Alert[key] = (propsData = {}, callback) => {
        return {
            show() {
                const Component = Vue.extend({
                    ...modules[key],
                    store: sweetStore,
                    router
                })
                const contruction = new Component({
                    propsData,
                    i18n: global.$i18n,
                }).$mount()
                if (callback) contruction.callback = callback
                document.body.appendChild(contruction.$el)
                contruction.dialogVisible = true
            }
        }
    }
}
export default Alert
suitabilityFn() {
      Dialog.suitability({
        problemInfo: this.mCurrentRow,
      }).show();
    },

猜你喜欢

转载自blog.csdn.net/qq_42306443/article/details/121531778