diff --git a/components/vc-dialog/DialogWrap.jsx b/components/vc-dialog/DialogWrap.jsx index 682edc93f..39b2c61ea 100644 --- a/components/vc-dialog/DialogWrap.jsx +++ b/components/vc-dialog/DialogWrap.jsx @@ -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',