From 1800f12e25210a16b4a0e2ea9864d2495171179a Mon Sep 17 00:00:00 2001 From: songchenglin3 <353833373@qq.com> Date: Wed, 15 Jan 2025 18:15:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=97=E6=8E=A7=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=E8=BF=94=E5=9B=9E=E7=9A=84selectedOptions=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E6=A0=A1=E9=AA=8C=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/datepicker/datepicker.taro.tsx | 14 ++++++++++++++ src/packages/datepicker/datepicker.tsx | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/packages/datepicker/datepicker.taro.tsx b/src/packages/datepicker/datepicker.taro.tsx index 2d14f28e42..a8c03ffd28 100644 --- a/src/packages/datepicker/datepicker.taro.tsx +++ b/src/packages/datepicker/datepicker.taro.tsx @@ -270,6 +270,20 @@ export const DatePicker: FunctionComponent< Number(formatDate[2]), getMonthEndDay(Number(formatDate[0]), Number(formatDate[1])) ) + + if ( + selectedOptions.length >= 2 && + (rangeType === 'date' || + rangeType === 'month-day' || + rangeType === 'datetime') + ) { + const dayOption = formatOption('day', day) + if (rangeType === 'month-day') { + selectedOptions[1] = dayOption + } else { + selectedOptions[2] = dayOption + } + } let date: Date | null = null if ( rangeType === 'date' || diff --git a/src/packages/datepicker/datepicker.tsx b/src/packages/datepicker/datepicker.tsx index 7a7f818b20..5a02905bf5 100644 --- a/src/packages/datepicker/datepicker.tsx +++ b/src/packages/datepicker/datepicker.tsx @@ -270,6 +270,20 @@ export const DatePicker: FunctionComponent< Number(formatDate[2]), getMonthEndDay(Number(formatDate[0]), Number(formatDate[1])) ) + + if ( + selectedOptions.length >= 2 && + (rangeType === 'date' || + rangeType === 'month-day' || + rangeType === 'datetime') + ) { + const dayOption = formatOption('day', day) + if (rangeType === 'month-day') { + selectedOptions[1] = dayOption + } else { + selectedOptions[2] = dayOption + } + } let date: Date | null = null if ( rangeType === 'date' ||