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 { getStyle, getClass } from '../_util/props-util';
|
||||
const IDialogPropTypes = getDialogPropTypes();
|
||||
let openCount = 0;
|
||||
const DialogWrap = {
|
||||
props: {
|
||||
...IDialogPropTypes,
|
||||
visible: IDialogPropTypes.visible.def(false),
|
||||
},
|
||||
data() {
|
||||
openCount = this.visible ? openCount + 1 : openCount;
|
||||
this.renderComponent = () => {};
|
||||
this.removeContainer = () => {};
|
||||
return {};
|
||||
},
|
||||
|
||||
watch: {
|
||||
visible(val, preVal) {
|
||||
openCount = val && !preVal ? openCount + 1 : openCount - 1;
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.visible) {
|
||||
openCount = openCount ? openCount - 1 : openCount;
|
||||
this.renderComponent({
|
||||
afterClose: this.removeContainer,
|
||||
visible: false,
|
||||
|
@ -29,7 +36,7 @@ const DialogWrap = {
|
|||
},
|
||||
methods: {
|
||||
getComponent(extra = {}) {
|
||||
const { $attrs, $listeners, $props, $slots } = this;
|
||||
const { $attrs, $listeners, $props, $slots, getContainer } = this;
|
||||
const { on, ...otherProps } = extra;
|
||||
const dialogProps = {
|
||||
props: {
|
||||
|
@ -37,6 +44,7 @@ const DialogWrap = {
|
|||
dialogClass: getClass(this),
|
||||
dialogStyle: getStyle(this),
|
||||
...otherProps,
|
||||
getOpenCount: getContainer === false ? () => 2 : () => openCount,
|
||||
},
|
||||
attrs: $attrs,
|
||||
ref: '_component',
|
||||
|
|
Loading…
Reference in New Issue