From a830c230af5084861f82055f3d1896301bf5bae7 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 4 Apr 2024 15:23:38 +0800 Subject: [PATCH] chore: correct return type of getSelectedTime (#12768) --- packages/vant/src/date-picker/DatePicker.tsx | 12 +++++------- packages/vant/src/date-picker/README.md | 2 +- packages/vant/src/date-picker/README.zh-CN.md | 8 ++++---- packages/vant/src/time-picker/README.md | 2 +- packages/vant/src/time-picker/README.zh-CN.md | 8 ++++---- packages/vant/src/time-picker/TimePicker.tsx | 18 +++++++----------- 6 files changed, 22 insertions(+), 28 deletions(-) diff --git a/packages/vant/src/date-picker/DatePicker.tsx b/packages/vant/src/date-picker/DatePicker.tsx index 9152acb52..47a4eca11 100644 --- a/packages/vant/src/date-picker/DatePicker.tsx +++ b/packages/vant/src/date-picker/DatePicker.tsx @@ -18,9 +18,11 @@ import { formatValueRange, } from './utils'; +// Composables +import { useExpose } from '../composables/use-expose'; + // Components import { Picker, PickerInstance } from '../picker'; -import { useExpose } from '../composables/use-expose'; const currentYear = new Date().getFullYear(); const [name] = createNamespace('date-picker'); @@ -134,13 +136,9 @@ export default defineComponent({ return genOptions(minDate, maxDate, 'day', props.formatter, props.filter); }; - const confirm = () => { - return pickerRef.value?.confirm(); - }; + const confirm = () => pickerRef.value?.confirm(); - const getSelectedDate = () => { - return currentValues.value; - }; + const getSelectedDate = () => currentValues.value; const columns = computed(() => props.columnsType.map((type) => { diff --git a/packages/vant/src/date-picker/README.md b/packages/vant/src/date-picker/README.md index e2969751e..fbd249ffb 100644 --- a/packages/vant/src/date-picker/README.md +++ b/packages/vant/src/date-picker/README.md @@ -211,7 +211,7 @@ Use [ref](https://vuejs.org/guide/essentials/template-refs.html) to get Picker i | Name | Description | Attribute | Return value | | --- | --- | --- | --- | | confirm | Stop scrolling and emit confirm event | - | - | -| getSelectedDate | Get current selected date | - | _string[] \| undefined_ | +| getSelectedDate | Get current selected date | - | _string[]_ | ### Types diff --git a/packages/vant/src/date-picker/README.zh-CN.md b/packages/vant/src/date-picker/README.zh-CN.md index 6b5a4668d..0cef30a83 100644 --- a/packages/vant/src/date-picker/README.zh-CN.md +++ b/packages/vant/src/date-picker/README.zh-CN.md @@ -214,10 +214,10 @@ export default { 通过 ref 可以获取到 Picker 实例并调用实例方法,详见[组件实例方法](#/zh-CN/advanced-usage#zu-jian-shi-li-fang-fa)。 -| 方法名 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| confirm | 停止惯性滚动并触发 `confirm` 事件 | - | - | -| getSelectedDate | 获取当前选中的日期 | - | _string[] \| undefined_ | +| 方法名 | 说明 | 参数 | 返回值 | +| --------------- | --------------------------------- | ---- | ---------- | +| confirm | 停止惯性滚动并触发 `confirm` 事件 | - | - | +| getSelectedDate | 获取当前选中的日期 | - | _string[]_ | ### 类型定义 diff --git a/packages/vant/src/time-picker/README.md b/packages/vant/src/time-picker/README.md index 79bbc93c0..93a85687e 100644 --- a/packages/vant/src/time-picker/README.md +++ b/packages/vant/src/time-picker/README.md @@ -290,7 +290,7 @@ Use [ref](https://vuejs.org/guide/essentials/template-refs.html) to get Picker i | Name | Description | Attribute | Return value | | --- | --- | --- | --- | | confirm | Stop scrolling and emit confirm event | - | - | -| getSelectedTime | Get current selected time | - | _string[] \| undefined_ | +| getSelectedTime | Get current selected time | - | _string[]_ | ### Types diff --git a/packages/vant/src/time-picker/README.zh-CN.md b/packages/vant/src/time-picker/README.zh-CN.md index 21f885845..bec02ee17 100644 --- a/packages/vant/src/time-picker/README.zh-CN.md +++ b/packages/vant/src/time-picker/README.zh-CN.md @@ -288,10 +288,10 @@ export default { 通过 ref 可以获取到 Picker 实例并调用实例方法,详见[组件实例方法](#/zh-CN/advanced-usage#zu-jian-shi-li-fang-fa)。 -| 方法名 | 说明 | 参数 | 返回值 | -| --- | --- | --- | --- | -| confirm | 停止惯性滚动并触发 `confirm` 事件 | - | - | -| getSelectedTime | 获取当前选中的时间 | - | _string[] \| undefined_ | +| 方法名 | 说明 | 参数 | 返回值 | +| --------------- | --------------------------------- | ---- | ---------- | +| confirm | 停止惯性滚动并触发 `confirm` 事件 | - | - | +| getSelectedTime | 获取当前选中的时间 | - | _string[]_ | ### 类型定义 diff --git a/packages/vant/src/time-picker/TimePicker.tsx b/packages/vant/src/time-picker/TimePicker.tsx index 5075ff717..ef49d3a33 100644 --- a/packages/vant/src/time-picker/TimePicker.tsx +++ b/packages/vant/src/time-picker/TimePicker.tsx @@ -17,19 +17,19 @@ import { type TimeFilter, } from '../date-picker/utils'; import { - createNamespace, + pick, extend, isSameValue, makeNumericProp, - pick, + createNamespace, } from '../utils'; -// Components -import { Picker, PickerInstance } from '../picker'; - // Composables import { useExpose } from '../composables/use-expose'; +// Components +import { Picker, PickerInstance } from '../picker'; + const [name] = createNamespace('time-picker'); export type TimePickerColumnType = 'hour' | 'minute' | 'second'; @@ -90,13 +90,9 @@ export default defineComponent({ ); }; - const confirm = () => { - return pickerRef.value?.confirm(); - }; + const confirm = () => pickerRef.value?.confirm(); - const getSelectedTime = (): string[] => { - return currentValues.value; - }; + const getSelectedTime = () => currentValues.value; const columns = computed(() => { let { minHour, maxHour, minMinute, maxMinute, minSecond, maxSecond } =