import ConfirmVue from './src/confirm.vue' let instance let Confirm = { install(Vue) { Vue.prototype.$confirm = function (opts) { let defaultOpts = { title: '', text: '', confirmTxt: '确定', cancelTxt: '取消' } if (!instance) { instance = new ConfirmVue({ el: document.createElement('div') }) } // 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 Confirm