import AlertVue from './src/alert.vue' let instance let Alert = { install(Vue) { Vue.prototype.$alert = function (opts) { let defaultOpts = { title: '', text: '', button: '确定' } if (!instance) { instance = new AlertVue({ el: document.createElement('div') }) } if (opts.close) { Vue.nextTick(() => { instance.show = false }) return } // let options = Object.assign(defaultOpts, opts) // Object.assign(instance, options) for(var key in opts){ if(opts.hasOwnProperty(key) === true){ defaultOpts[key]=opts[key]; } } var options = defaultOpts for(var key in options){ if(options.hasOwnProperty(key) === true){ instance[key]=options[key]; } } document.body.appendChild(instance.$el) Vue.nextTick(() => { instance.show = true }) } } } export default Alert