diff --git a/components/UiConfirm.vue b/components/UiConfirm.vue new file mode 100644 index 0000000..3ffe1cb --- /dev/null +++ b/components/UiConfirm.vue @@ -0,0 +1,55 @@ + + + \ No newline at end of file diff --git a/components/mount/index.js b/components/mount/index.js new file mode 100644 index 0000000..3f53c5d --- /dev/null +++ b/components/mount/index.js @@ -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 } + + } +} \ No newline at end of file diff --git a/main.js b/main.js index 91ca80e..c43fe4b 100644 --- a/main.js +++ b/main.js @@ -2,7 +2,7 @@ * @Author: ch * @Date: 2021-07-26 23:22:16 * @LastEditors: ch - * @LastEditTime: 2022-03-29 11:14:39 + * @LastEditTime: 2022-04-19 17:26:10 * @Description: file content */ import Vue from 'vue'; @@ -10,11 +10,13 @@ import App from './App'; import {router,RouterMount} from '@/common/router/index.js'; import uView from 'uview-ui'; -import store from '@/common/store' +import store from '@/common/store'; +import Confirm from '@/components/mount/index'; Vue.use(router); Vue.use(uView); +Vue.use(Confirm); Vue.prototype.$store = store Vue.config.productionTip = false; diff --git a/pages/account/setting/index.vue b/pages/account/setting/index.vue index d84fed1..186d358 100644 --- a/pages/account/setting/index.vue +++ b/pages/account/setting/index.vue @@ -2,7 +2,7 @@ * @Author: ch * @Date: 2022-03-22 15:09:06 * @LastEditors: ch - * @LastEditTime: 2022-04-19 15:56:51 + * @LastEditTime: 2022-04-19 17:20:30 * @Description: file content -->