chore: improve multiple watch source (#8253)

This commit is contained in:
neverland
2021-03-03 16:32:38 +08:00
committed by GitHub
parent 7f4651bbbf
commit 202edb24c7
6 changed files with 22 additions and 20 deletions
+6 -3
View File
@@ -503,9 +503,12 @@ export default createComponent({
);
watch(() => props.show, init);
watch([() => props.type, () => props.minDate, () => props.maxDate], () => {
reset(getInitialDate(state.currentDate));
});
watch(
() => [props.type, props.minDate, props.maxDate],
() => {
reset(getInitialDate(state.currentDate));
}
);
watch(
() => props.defaultDate,
(value) => {
+2 -6
View File
@@ -33,12 +33,8 @@ export default createComponent({
const { start, pause, reset, current } = useCountDown({
time: +props.time,
millisecond: props.millisecond,
onChange(current) {
emit('change', current);
},
onFinish() {
emit('finish');
},
onChange: (current) => emit('change', current),
onFinish: () => emit('finish'),
});
const timeText = computed(() => parseFormat(props.format, current.value));
+1 -1
View File
@@ -173,7 +173,7 @@ export default createComponent({
// see: https://guwii.com/cache-issues-with-forwards-and-back-history-in-safari/
useEventListener('pageshow', start);
watch([() => props.text, () => props.scrollable], start);
watch(() => [props.text, props.scrollable], start);
return () => {
const { color, wrapable, background } = props;
+1 -1
View File
@@ -175,7 +175,7 @@ export default createComponent({
}
});
watch([() => props.show, () => props.placement], updateLocation);
watch(() => [props.show, props.placement], updateLocation);
useClickAway(wrapperRef, onClickAway, { eventName: 'touchstart' });
+1 -1
View File
@@ -66,7 +66,7 @@ export default createComponent({
}
};
watch([() => props.showPivot, () => props.pivotText], resize);
watch(() => [props.showPivot, props.pivotText], resize);
onMounted(resize);
useExpose({ resize });
+11 -8
View File
@@ -103,16 +103,19 @@ export default createComponent({
}
};
watch([() => props.show, () => props.forbidClick], toggleClickable);
watch(() => [props.show, props.forbidClick], toggleClickable);
watch([() => props.show, () => props.duration], () => {
clearTimer();
if (props.show && props.duration > 0) {
timer = setTimeout(() => {
updateShow(false);
}, props.duration);
watch(
() => [props.show, props.duration],
() => {
clearTimer();
if (props.show && props.duration > 0) {
timer = setTimeout(() => {
updateShow(false);
}, props.duration);
}
}
});
);
onMounted(toggleClickable);
onUnmounted(toggleClickable);