From 6291998e8c4e0dcd70571cbe404e228b89b71c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Sun, 3 Dec 2023 21:32:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/time-picker/panel/single-panel.tsx | 8 ++++---- src/time-picker/panel/time-picker-panel.tsx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/time-picker/panel/single-panel.tsx b/src/time-picker/panel/single-panel.tsx index 3101311f38..2ec2f1ac75 100644 --- a/src/time-picker/panel/single-panel.tsx +++ b/src/time-picker/panel/single-panel.tsx @@ -51,7 +51,7 @@ export default defineComponent({ const colsRef = reactive({ 0: null, 1: null, 2: null, 3: null, 4: null, 5: null }); const dayjsValue = computed(() => { - const isStepsSet = !!steps.value.filter((v) => v > 1).length; + const isStepsSet = !!steps.value.filter((step) => Number(step) > 1).length; if (value.value) return dayjs(value.value, format.value); @@ -271,9 +271,9 @@ export default defineComponent({ } else { const currentHour = dayjsValue.value.hour(); if (el === AM && currentHour >= 12) { - props.onChange(dayjsValue.value.hour(currentHour - 12).format(format.value), e); + props.onChange?.(dayjsValue.value.hour(currentHour - 12).format(format.value), e); } else if (el === PM && currentHour < 12) { - props.onChange(dayjsValue.value.hour(currentHour + 12).format(format.value), e); + props.onChange?.(dayjsValue.value.hour(currentHour + 12).format(format.value), e); } } }; @@ -281,7 +281,7 @@ export default defineComponent({ // update each columns scroll distance const updateTimeScrollPos = (isAutoScroll = false) => { const behavior = value.value && !isAutoScroll ? 'smooth' : 'auto'; - const isStepsSet = !!steps.value.filter((v) => v > 1).length; + const isStepsSet = !!steps.value.filter((step) => Number(step) > 1).length; nextTick(() => { cols.value.forEach((col: EPickerCols, idx: number) => { if (!isStepsSet || (isStepsSet && value.value)) { diff --git a/src/time-picker/panel/time-picker-panel.tsx b/src/time-picker/panel/time-picker-panel.tsx index d7d2fefa7b..6fba488974 100644 --- a/src/time-picker/panel/time-picker-panel.tsx +++ b/src/time-picker/panel/time-picker-panel.tsx @@ -100,7 +100,7 @@ export default defineComponent({ theme="primary" variant="base" disabled={!props.value} - onClick={() => props.handleConfirmClick(defaultValue.value)} + onClick={() => props.handleConfirmClick?.(defaultValue.value)} size="small" > {globalConfig.value.confirm} @@ -110,7 +110,7 @@ export default defineComponent({ theme="primary" variant="text" size="small" - onClick={() => props.onChange(dayjs().format(props.format))} + onClick={() => props.onChange?.(dayjs().format(props.format))} > {globalConfig.value.now}