Browse Source

fix: notification onClose event runs repeatedly (#6150)

pull/6152/head
Konv Suu 2 years ago committed by GitHub
parent
commit
7ea18a8287
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      components/vc-notification/Notice.tsx

6
components/vc-notification/Notice.tsx

@ -46,9 +46,10 @@ export default defineComponent<NoticeProps>({
] as any,
setup(props, { attrs, slots }) {
let closeTimer: any;
const duration = computed(() => (props.duration === undefined ? 1.5 : props.duration));
let isUnMounted = false;
const duration = computed(() => (props.duration === undefined ? 4.5 : props.duration));
const startCloseTimer = () => {
if (duration.value) {
if (duration.value && !isUnMounted) {
closeTimer = setTimeout(() => {
close();
}, duration.value * 1000);
@ -79,6 +80,7 @@ export default defineComponent<NoticeProps>({
startCloseTimer();
});
onUnmounted(() => {
isUnMounted = true;
clearCloseTimer();
});

Loading…
Cancel
Save