mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: improve multiple watch source (#8253)
This commit is contained in:
parent
7f4651bbbf
commit
202edb24c7
@ -503,9 +503,12 @@ export default createComponent({
|
|||||||
);
|
);
|
||||||
|
|
||||||
watch(() => props.show, init);
|
watch(() => props.show, init);
|
||||||
watch([() => props.type, () => props.minDate, () => props.maxDate], () => {
|
watch(
|
||||||
reset(getInitialDate(state.currentDate));
|
() => [props.type, props.minDate, props.maxDate],
|
||||||
});
|
() => {
|
||||||
|
reset(getInitialDate(state.currentDate));
|
||||||
|
}
|
||||||
|
);
|
||||||
watch(
|
watch(
|
||||||
() => props.defaultDate,
|
() => props.defaultDate,
|
||||||
(value) => {
|
(value) => {
|
||||||
|
@ -33,12 +33,8 @@ export default createComponent({
|
|||||||
const { start, pause, reset, current } = useCountDown({
|
const { start, pause, reset, current } = useCountDown({
|
||||||
time: +props.time,
|
time: +props.time,
|
||||||
millisecond: props.millisecond,
|
millisecond: props.millisecond,
|
||||||
onChange(current) {
|
onChange: (current) => emit('change', current),
|
||||||
emit('change', current);
|
onFinish: () => emit('finish'),
|
||||||
},
|
|
||||||
onFinish() {
|
|
||||||
emit('finish');
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const timeText = computed(() => parseFormat(props.format, current.value));
|
const timeText = computed(() => parseFormat(props.format, current.value));
|
||||||
|
@ -173,7 +173,7 @@ export default createComponent({
|
|||||||
// see: https://guwii.com/cache-issues-with-forwards-and-back-history-in-safari/
|
// see: https://guwii.com/cache-issues-with-forwards-and-back-history-in-safari/
|
||||||
useEventListener('pageshow', start);
|
useEventListener('pageshow', start);
|
||||||
|
|
||||||
watch([() => props.text, () => props.scrollable], start);
|
watch(() => [props.text, props.scrollable], start);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const { color, wrapable, background } = props;
|
const { color, wrapable, background } = props;
|
||||||
|
@ -175,7 +175,7 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch([() => props.show, () => props.placement], updateLocation);
|
watch(() => [props.show, props.placement], updateLocation);
|
||||||
|
|
||||||
useClickAway(wrapperRef, onClickAway, { eventName: 'touchstart' });
|
useClickAway(wrapperRef, onClickAway, { eventName: 'touchstart' });
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch([() => props.showPivot, () => props.pivotText], resize);
|
watch(() => [props.showPivot, props.pivotText], resize);
|
||||||
onMounted(resize);
|
onMounted(resize);
|
||||||
useExpose({ resize });
|
useExpose({ resize });
|
||||||
|
|
||||||
|
@ -103,16 +103,19 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch([() => props.show, () => props.forbidClick], toggleClickable);
|
watch(() => [props.show, props.forbidClick], toggleClickable);
|
||||||
|
|
||||||
watch([() => props.show, () => props.duration], () => {
|
watch(
|
||||||
clearTimer();
|
() => [props.show, props.duration],
|
||||||
if (props.show && props.duration > 0) {
|
() => {
|
||||||
timer = setTimeout(() => {
|
clearTimer();
|
||||||
updateShow(false);
|
if (props.show && props.duration > 0) {
|
||||||
}, props.duration);
|
timer = setTimeout(() => {
|
||||||
|
updateShow(false);
|
||||||
|
}, props.duration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
onMounted(toggleClickable);
|
onMounted(toggleClickable);
|
||||||
onUnmounted(toggleClickable);
|
onUnmounted(toggleClickable);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user