@@ -3,19 +3,26 @@ import ContainerRender from '../_util/ContainerRender';
3
3
import getDialogPropTypes from './IDialogPropTypes' ;
4
4
import { getStyle , getClass } from '../_util/props-util' ;
5
5
const IDialogPropTypes = getDialogPropTypes ( ) ;
6
+ let openCount = 0 ;
6
7
const DialogWrap = {
7
8
props : {
8
9
...IDialogPropTypes ,
9
10
visible : IDialogPropTypes . visible . def ( false ) ,
10
11
} ,
11
12
data ( ) {
13
+ openCount = this . visible ? openCount + 1 : openCount ;
12
14
this . renderComponent = ( ) => { } ;
13
15
this . removeContainer = ( ) => { } ;
14
16
return { } ;
15
17
} ,
16
-
18
+ watch : {
19
+ visible ( val , preVal ) {
20
+ openCount = val && ! preVal ? openCount + 1 : openCount - 1 ;
21
+ } ,
22
+ } ,
17
23
beforeDestroy ( ) {
18
24
if ( this . visible ) {
25
+ openCount = openCount ? openCount - 1 : openCount ;
19
26
this . renderComponent ( {
20
27
afterClose : this . removeContainer ,
21
28
visible : false ,
@@ -29,14 +36,15 @@ const DialogWrap = {
29
36
} ,
30
37
methods : {
31
38
getComponent ( extra = { } ) {
32
- const { $attrs, $listeners, $props, $slots } = this ;
39
+ const { $attrs, $listeners, $props, $slots, getContainer } = this ;
33
40
const { on, ...otherProps } = extra ;
34
41
const dialogProps = {
35
42
props : {
36
43
...$props ,
37
44
dialogClass : getClass ( this ) ,
38
45
dialogStyle : getStyle ( this ) ,
39
46
...otherProps ,
47
+ getOpenCount : getContainer === false ? ( ) => 2 : ( ) => openCount ,
40
48
} ,
41
49
attrs : $attrs ,
42
50
ref : '_component' ,
0 commit comments