From 945d71b3bc4b42e28cdca08ce7acf59e45923308 Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期五, 16 四月 2021 14:38:08 +0800
Subject: [PATCH] 弹框组件
---
src/components/layer/src/layer.js | 58 +++++++++++++++++-----------------------------------------
1 files changed, 17 insertions(+), 41 deletions(-)
diff --git a/src/components/layer/src/layer.js b/src/components/layer/src/layer.js
index b42ef27..2d2db28 100644
--- a/src/components/layer/src/layer.js
+++ b/src/components/layer/src/layer.js
@@ -1,27 +1,12 @@
import layerVue from './layer.vue'
-const Notification = function (Vue, globalOption = {
- msgtime: 1.5 // msg娑堝け鏃堕棿
-}) {
- const NotificationConstructor = Vue.extend(layerVue)
+const Layer = function (Vue) {
+ const LayerVueExtend = Vue.extend(layerVue)
const self = {}
const defOptions = {
type: 0, // 0锛堜俊鎭锛岄粯璁わ級1锛堥〉闈㈠眰锛�2锛坕frame灞傦級3锛堝姞杞藉眰锛�4锛坱ips灞傦級,5msg,6prompt
title: '淇℃伅',
content: '',
- area: 'auto',
- offset: 'auto',
- icon: -1,
- btn: '纭畾',
- time: 0,
- maxmin: false, // 鏈�澶ф渶灏忓寲
- shade: true,
- yes: '',
- cancel: '',
- tips: [0, {}], // 鏀寔涓婂彸涓嬪乏鍥涗釜鏂瑰悜锛岄�氳繃1-4杩涜鏂瑰悜璁惧畾,鍙互璁惧畾tips: [1, '#c00']
- tipsMore: false, // 鏄惁鍏佽澶氫釜tips
- shadeClose: true,
- scrollbar: true, // 鏄惁鍏佽娴忚鍣ㄥ嚭鐜版粴鍔ㄦ潯:榛樿鏄厑璁�
- resize: false // 鏄惁鍏佽鎷変几锛岄粯璁ゆ槸涓嶅厑璁�
+ btn: '纭畾'
}
self.instances = {}
self.instancesVue = []
@@ -34,17 +19,20 @@
* @param {[type]} options [description]
* @return {[type]} [description]
*/
- self.open = function (options) {
- options = mergeJson(options, defOptions)
+ self.open = function (opt) {
+ /* let option = {
+ type: 1,
+ content: opt.content,
+ area: opt.area
+ } */
+ var options = mergeJson(opt, defOptions)
const id = `notification_${new Date().getTime()}_${seed++}`
options.id = id
options.layer = self
- const instance = new NotificationConstructor({
+ options.content.content = Vue.extend(options.content.content)
+ const instance = new LayerVueExtend({
data: options
})
- if (options.type === 1) {
- options.content.content = Vue.extend(options.content.content)
- }
instance.id = id
instance.vm = instance.$mount()
self.instances[id] = {
@@ -52,6 +40,7 @@
type: options.type
}
document.body.appendChild(instance.vm.$el)
+ instance.init()
self.instancesVue[id] = {
mask: '',
main: instance.vm,
@@ -59,28 +48,15 @@
}
return id
}
- /**
- * [description]
- * @param {[type]} options [description]
- * @return {[type]} [description]
- */
- self.iframe = function (opt) {
- let option = {
- type: 1,
- content: opt.content,
- area: opt.area
- }
- option = mergeJson(option, opt)
- console.log(option)
- return self.open(option)
- }
+
/**
* 鍏抽棴涓�涓脊绐�
* @param {[type]} id [description]
* @return {[type]} [description]
*/
self.close = function (id) {
- const oElm = document.getElementById(id)
+ console.log(id)
+ const oElm = document.getElementById(id).parentElement
if (oElm) {
document.body.removeChild(oElm)
delete self.instances[id]
@@ -192,4 +168,4 @@
}
// module.exports = Notification;
-export default Notification
+export default Layer
--
Gitblit v1.8.0