parent
5bf934105e
commit
55381c3fea
@ -0,0 +1,55 @@
|
||||
<!--
|
||||
* @Author: ch
|
||||
* @Date: 2022-04-19 16:19:32
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-04-19 17:29:48
|
||||
* @Description: file content
|
||||
-->
|
||||
<template>
|
||||
<u-modal :show="show" :content="content" showCancelButton
|
||||
@confirm="myConfirm" @cancel="myCancel"/>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props : {
|
||||
content : {
|
||||
type : String,
|
||||
default : ''
|
||||
},
|
||||
confirmTxt : {
|
||||
type : String,
|
||||
default : '确认'
|
||||
},
|
||||
confirm : {
|
||||
type : Function,
|
||||
default: function(){}
|
||||
},
|
||||
cancelTxt : {
|
||||
type : String,
|
||||
default : '取消'
|
||||
},
|
||||
cancel : {
|
||||
type : Function,
|
||||
default : function(){}
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
show : true
|
||||
}
|
||||
},
|
||||
methods : {
|
||||
async myConfirm(){
|
||||
this.show = false;
|
||||
await this.confirm();
|
||||
document.body.removeChild(this.$el);
|
||||
|
||||
},
|
||||
async myCancel(){
|
||||
this.show = false;
|
||||
await this.cancel();
|
||||
document.body.removeChild(this.$el);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* @Author: ch
|
||||
* @Date: 2022-04-19 16:14:03
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-04-19 17:20:08
|
||||
* @Description: file content
|
||||
*/
|
||||
import Confirm from '../UiConfirm.vue';
|
||||
|
||||
export default {
|
||||
install (Vue) {
|
||||
// 创建构造类
|
||||
const ConfirmConstructor = Vue.extend(Confirm)
|
||||
|
||||
const showNextConfirm = function (options) {
|
||||
// 实例化组件
|
||||
const instance = new ConfirmConstructor({
|
||||
el: document.createElement('div')
|
||||
})
|
||||
// 处理参数
|
||||
for (const prop in options) {
|
||||
instance[prop] = options[prop];
|
||||
}
|
||||
// 插入Body
|
||||
document.body.appendChild(instance.$el)
|
||||
Vue.nextTick(() => {
|
||||
instance.show = true
|
||||
})
|
||||
}
|
||||
|
||||
const confirmFn = (options) => {
|
||||
return showNextConfirm(options);
|
||||
}
|
||||
Vue.prototype.$msb ?
|
||||
Vue.prototype.$msb.confirm = confirmFn :
|
||||
Vue.prototype.$msb={confirm : confirmFn }
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in new issue