fix(Toast): shoud watch duration #7394

This commit is contained in:
chenjiahan 2020-10-23 22:12:21 +08:00
parent d7a944e391
commit bd1ed1c1ce

View File

@ -94,17 +94,14 @@ export default createComponent({
watch([() => props.show, () => props.forbidClick], toggleClickable);
watch(
() => props.show,
(value) => {
clearTimer();
if (value && props.duration > 0) {
timer = setTimeout(() => {
emit('update:show', false);
}, props.duration);
}
watch([() => props.show, () => props.duration], () => {
clearTimer();
if (props.show && props.duration > 0) {
timer = setTimeout(() => {
emit('update:show', false);
}, props.duration);
}
);
});
onMounted(toggleClickable);
onUnmounted(toggleClickable);