diff --git a/src/components/popup/index.vue b/src/components/popup/index.vue
index 10b3bba4d..0e8588cce 100755
--- a/src/components/popup/index.vue
+++ b/src/components/popup/index.vue
@@ -74,18 +74,26 @@ export default {
for (let i = 0; i < this.$overflowScrollingList.length; i++) {
this.$overflowScrollingList[i].style.webkitOverflowScrolling = type
}
+ },
+ updateZIndex () {
+ window.popupIndex = window.popupIndex || 250
+ window.popupIndex += 1
+ this.showIndex = window.popupIndex * 2 + 1
}
},
data () {
return {
initialShow: true,
hasFirstShow: false,
- show: this.value
+ show: this.value,
+ showIndex: 501
}
},
computed: {
styles () {
- const styles = {}
+ const styles = {
+ 'z-index': this.showIndex
+ }
if (!this.position || this.position === 'bottom' || this.position === 'top') {
styles.height = this.height
} else {
@@ -107,6 +115,7 @@ export default {
show (val) {
this.$emit('input', val)
if (val) {
+ this.updateZIndex()
this.popup && this.popup.show()
this.$emit('on-show')
this.fixSafariOverflowScrolling('auto')
diff --git a/src/components/popup/metas.yml b/src/components/popup/metas.yml
index 99ac7da30..230ce9308 100644
--- a/src/components/popup/metas.yml
+++ b/src/components/popup/metas.yml
@@ -113,4 +113,8 @@ changes:
- '[fix] Fix overflow-scrolling setting in safari #311 @linhaobin'
zh-CN:
- '[fix] 修复 `overflow-scrolling` 设置逻辑遗漏问题 #311 @linhaobin'
-
+ next:
+ en:
+ - '[feature] Support multiple popup'
+ zh-CN:
+ - '[feature] 支持多层popup'
diff --git a/src/components/popup/popup.js b/src/components/popup/popup.js
index 170ce443a..89c8fdfe2 100755
--- a/src/components/popup/popup.js
+++ b/src/components/popup/popup.js
@@ -11,13 +11,11 @@ const popupDialog = function (option) {
showMask: option.showMask
}
}
- if (!!document.querySelectorAll('.vux-popup-mask').length <= 0) {
- this.divMask = document.createElement('a')
- this.divMask.className = 'vux-popup-mask'
- this.divMask.dataset.uuid = ''
- this.divMask.href = 'javascript:void(0)'
- document.body.appendChild(this.divMask)
- }
+ this.divMask = document.createElement('a')
+ this.divMask.className = 'vux-popup-mask'
+ this.divMask.dataset.uuid = ''
+ this.divMask.href = 'javascript:void(0)'
+ document.body.appendChild(this.divMask)
let div
if (!option.container) {
div = document.createElement('div')
@@ -36,7 +34,7 @@ const popupDialog = function (option) {
document.body.appendChild(div)
}
this.container = document.querySelector('.vux-popup-dialog-' + this.uuid)
- this.mask = document.querySelector('.vux-popup-mask')
+ this.mask = this.divMask
this.mask.dataset.uuid += `,${this.uuid}`
this._bindEvents()
option = null
@@ -64,7 +62,7 @@ popupDialog.prototype._bindEvents = function () {
popupDialog.prototype.show = function () {
if (this.params.showMask) {
this.mask.classList.add('vux-popup-show')
- this.mask.style['zIndex'] = 500
+ this.mask.style['zIndex'] = (window.popupIndex || 250) * 2
}
this.container.classList.add('vux-popup-show')
this.params.onOpen && this.params.onOpen(this)
@@ -73,12 +71,10 @@ popupDialog.prototype.show = function () {
popupDialog.prototype.hide = function (shouldCallback = true) {
this.container.classList.remove('vux-popup-show')
- if (!document.querySelector('.vux-popup-dialog.vux-popup-show')) {
- this.mask.classList.remove('vux-popup-show')
- setTimeout(() => {
- this.mask && !/show/.test(this.mask.className) && (this.mask.style['zIndex'] = -1)
- }, 400)
- }
+ this.mask.classList.remove('vux-popup-show')
+ setTimeout(() => {
+ this.mask && !/show/.test(this.mask.className) && (this.mask.style['zIndex'] = -1)
+ }, 400)
shouldCallback === false && this.params.onClose && this.params.hideOnBlur && this.params.onClose(this)
this.isShow = false
delete window.__$vuxPopups[this.uuid]
diff --git a/src/demos/Popup.vue b/src/demos/Popup.vue
index 514fafc6f..57a15304c 100755
--- a/src/demos/Popup.vue
+++ b/src/demos/Popup.vue
@@ -10,7 +10,7 @@