vue-login-adder
Version:
a confirm plugin for vue
28 lines (27 loc) • 809 B
JavaScript
import confirm from "./confirm.vue";
function defaultCallBack (action){
if(!action){
currentMsg.reject();
}else{
currentMsg.resolve();
}
}
let Confirm = {}
let currentMsg = null
Confirm.install = function(Vue,options){
const confirmPlugin = Vue.extend(confirm);
confirmPlugin.prototype.callBack = defaultCallBack;
let instance = null;
Vue.prototype.$show = function(params){
console.log(11111)
if(!instance){
instance = new confirmPlugin().$mount(document.createElement('div'));
document.body.appendChild(instance.$el);
}
instance.giveData(params);
return new Promise((resolve,reject)=>{
currentMsg = {resolve,reject}
})
}
}
export default Confirm;