fix: body scroll when open modal #1472
parent
31dda9e9ce
commit
1f429c1e88
|
@ -3,19 +3,26 @@ import ContainerRender from '../_util/ContainerRender';
|
||||||
import getDialogPropTypes from './IDialogPropTypes';
|
import getDialogPropTypes from './IDialogPropTypes';
|
||||||
import { getStyle, getClass } from '../_util/props-util';
|
import { getStyle, getClass } from '../_util/props-util';
|
||||||
const IDialogPropTypes = getDialogPropTypes();
|
const IDialogPropTypes = getDialogPropTypes();
|
||||||
|
let openCount = 0;
|
||||||
const DialogWrap = {
|
const DialogWrap = {
|
||||||
props: {
|
props: {
|
||||||
...IDialogPropTypes,
|
...IDialogPropTypes,
|
||||||
visible: IDialogPropTypes.visible.def(false),
|
visible: IDialogPropTypes.visible.def(false),
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
openCount = this.visible ? openCount + 1 : openCount;
|
||||||
this.renderComponent = () => {};
|
this.renderComponent = () => {};
|
||||||
this.removeContainer = () => {};
|
this.removeContainer = () => {};
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
visible(val, preVal) {
|
||||||
|
openCount = val && !preVal ? openCount + 1 : openCount - 1;
|
||||||
|
},
|
||||||
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
if (this.visible) {
|
if (this.visible) {
|
||||||
|
openCount = openCount ? openCount - 1 : openCount;
|
||||||
this.renderComponent({
|
this.renderComponent({
|
||||||
afterClose: this.removeContainer,
|
afterClose: this.removeContainer,
|
||||||
visible: false,
|
visible: false,
|
||||||
|
@ -29,7 +36,7 @@ const DialogWrap = {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getComponent(extra = {}) {
|
getComponent(extra = {}) {
|
||||||
const { $attrs, $listeners, $props, $slots } = this;
|
const { $attrs, $listeners, $props, $slots, getContainer } = this;
|
||||||
const { on, ...otherProps } = extra;
|
const { on, ...otherProps } = extra;
|
||||||
const dialogProps = {
|
const dialogProps = {
|
||||||
props: {
|
props: {
|
||||||
|
@ -37,6 +44,7 @@ const DialogWrap = {
|
||||||
dialogClass: getClass(this),
|
dialogClass: getClass(this),
|
||||||
dialogStyle: getStyle(this),
|
dialogStyle: getStyle(this),
|
||||||
...otherProps,
|
...otherProps,
|
||||||
|
getOpenCount: getContainer === false ? () => 2 : () => openCount,
|
||||||
},
|
},
|
||||||
attrs: $attrs,
|
attrs: $attrs,
|
||||||
ref: '_component',
|
ref: '_component',
|
||||||
|
|
Loading…
Reference in New Issue