Skip to content

Commit 9004da3

Browse files
committed
feat: 标签调用
1 parent 73acdfe commit 9004da3

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/packages/notify/notify.vue

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<nut-popup
3-
v-model="showPopup"
3+
v-model="curVisible"
44
position="top"
55
:style="{'color':color,
66
'background': background}"
@@ -10,7 +10,12 @@
1010
@click="handleClick"
1111
@opened="handleOpened"
1212
@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>
1419
</template>
1520
<script>
1621
import { overlayProps, getProps } from '../popup/index';
@@ -23,7 +28,7 @@ export default {
2328
...overlayProps,
2429
color: { type: String, default: '' },
2530
msg: { type: [Number, String], default: '' },
26-
// duration: { type: [Number, String], default: 3000 },
31+
duration: { type: [Number, String], default: 3000 },
2732
className: {
2833
type: String,
2934
default: ''
@@ -39,14 +44,18 @@ export default {
3944
}
4045
},
4146
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+
}
4553
}
54+
// immediate: true
4655
}
4756
},
4857
data() {
49-
return { timer: null };
58+
return { timer: null, curVisible: false };
5059
},
5160
components: {
5261
'nut-popup': Popup
@@ -73,13 +82,13 @@ export default {
7382
},
7483
hide(force) {
7584
this.clearTimer();
76-
this.showPopup = false;
85+
this.curVisible = false;
7786
if (force) {
7887
clearTimeout(this.textTimer);
7988
} else {
8089
this.textTimer = setTimeout(() => {
8190
clearTimeout(this.textTimer);
82-
this.msg = '';
91+
// this.msg = '';
8392
}, 300);
8493
}
8594
},
@@ -90,9 +99,6 @@ export default {
9099
}
91100
}
92101
},
93-
mounted() {
94-
console.log(this, this.onClick, this.onOpened, this.onClosed, 'mounted');
95-
},
96102
destroyed() {
97103
this.textTimer = null;
98104
this.timer = null;

0 commit comments

Comments
 (0)