[Improvement] Popup: get-container support selector (#1699)
This commit is contained in:
@@ -21,7 +21,7 @@ export default {
|
||||
// z-index
|
||||
zIndex: [String, Number],
|
||||
// return the mount node for popup
|
||||
getContainer: Function,
|
||||
getContainer: [String, Function],
|
||||
// prevent body scroll
|
||||
lockScroll: {
|
||||
type: Boolean,
|
||||
@@ -139,10 +139,20 @@ export default {
|
||||
},
|
||||
|
||||
move() {
|
||||
if (this.getContainer) {
|
||||
this.getContainer().appendChild(this.$el);
|
||||
let container;
|
||||
|
||||
const { getContainer } = this;
|
||||
if (getContainer) {
|
||||
container =
|
||||
typeof getContainer === 'string'
|
||||
? document.querySelector(getContainer)
|
||||
: getContainer();
|
||||
} else if (this.$parent) {
|
||||
this.$parent.$el.appendChild(this.$el);
|
||||
container = this.$parent.$el;
|
||||
}
|
||||
|
||||
if (container) {
|
||||
container.appendChild(this.$el);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user