1
1
<template >
2
2
<nut-popup
3
- v-model =" showPopup "
3
+ v-model =" curVisible "
4
4
position =" top"
5
5
:style =" {'color':color,
6
6
'background': background}"
10
10
@click =" handleClick"
11
11
@opened =" handleOpened"
12
12
@closed =" handleClosed"
13
- >{{msg}}</nut-popup >
13
+ >
14
+ <template v-if =" $slots .default " >
15
+ <slot ></slot >
16
+ </template >
17
+ <template v-else >{{msg}}</template >
18
+ </nut-popup >
14
19
</template >
15
20
<script >
16
21
import { overlayProps , getProps } from ' ../popup/index' ;
@@ -23,7 +28,7 @@ export default {
23
28
... overlayProps,
24
29
color: { type: String , default: ' ' },
25
30
msg: { type: [Number , String ], default: ' ' },
26
- // duration: { type: [Number, String], default: 3000 },
31
+ duration: { type: [Number , String ], default: 3000 },
27
32
className: {
28
33
type: String ,
29
34
default: ' '
@@ -39,14 +44,18 @@ export default {
39
44
}
40
45
},
41
46
watch: {
42
- showPopup (val ) {
43
- if (val) {
44
- this .show ();
47
+ showPopup: {
48
+ handler (val ) {
49
+ if (val) {
50
+ this .curVisible = val;
51
+ this .show ();
52
+ }
45
53
}
54
+ // immediate: true
46
55
}
47
56
},
48
57
data () {
49
- return { timer: null };
58
+ return { timer: null , curVisible : false };
50
59
},
51
60
components: {
52
61
' nut-popup' : Popup
@@ -73,13 +82,13 @@ export default {
73
82
},
74
83
hide (force ) {
75
84
this .clearTimer ();
76
- this .showPopup = false ;
85
+ this .curVisible = false ;
77
86
if (force) {
78
87
clearTimeout (this .textTimer );
79
88
} else {
80
89
this .textTimer = setTimeout (() => {
81
90
clearTimeout (this .textTimer );
82
- this .msg = ' ' ;
91
+ // this.msg = '';
83
92
}, 300 );
84
93
}
85
94
},
@@ -90,9 +99,6 @@ export default {
90
99
}
91
100
}
92
101
},
93
- mounted () {
94
- console .log (this , this .onClick , this .onOpened , this .onClosed , ' mounted' );
95
- },
96
102
destroyed () {
97
103
this .textTimer = null ;
98
104
this .timer = null ;
0 commit comments