docs(datetime-picker): 添加 before-confirm 回调中使用loading的提示

在 DateTimePicker 组件的文档中添加了关于 before-confirm 回调函数的使用提示。说明了在调用 resolve 函数之前,需要确保 picker 参数的 loading 状态为 false,否则无法正确触发组件的 @confirm 事件。

- 在中文文档和英文文档中均添加了此提示信息
This commit is contained in:
weiye 2025-07-19 11:56:31 +08:00 committed by 不如摸鱼去
parent 5a458fc723
commit c61b33f51a
2 changed files with 8 additions and 0 deletions

View File

@ -197,6 +197,10 @@ const filter = (type, values) => {
设置 `before-confirm` 函数,在用户点击`确定`按钮时,会执行 `before-confirm` 函数,并传入 `value`(time 类型为字符串其他为时间戳当picker为区间选择时`value`为数组) 、 `resolve``picker` 参数,可以对 `value` 进行校验,并通过 `resolve` 函数告知组件是否确定通过,`resolve` 接受1个 boolean 值,`resolve(true)` 表示选项通过,`resolve(false)` 表示选项不通过,不通过时不会关闭 `picker`弹窗。可以通过 `picker` 参数直接设置 `loading` 等属性。 设置 `before-confirm` 函数,在用户点击`确定`按钮时,会执行 `before-confirm` 函数,并传入 `value`(time 类型为字符串其他为时间戳当picker为区间选择时`value`为数组) 、 `resolve``picker` 参数,可以对 `value` 进行校验,并通过 `resolve` 函数告知组件是否确定通过,`resolve` 接受1个 boolean 值,`resolve(true)` 表示选项通过,`resolve(false)` 表示选项不通过,不通过时不会关闭 `picker`弹窗。可以通过 `picker` 参数直接设置 `loading` 等属性。
:::tip 提示
在调用 `resolve` 之前须确保 `picker` 参数 `loading` 的加载状态为 `false` ,否则无法正确触发组件的 `@confirm` 事件。
:::
```html ```html
<wd-toast></wd-toast> <wd-toast></wd-toast>
<wd-datetime-picker label="before-confirm" v-model="value" :before-confirm="beforeConfirm" @confirm="handleConfirm" /> <wd-datetime-picker label="before-confirm" v-model="value" :before-confirm="beforeConfirm" @confirm="handleConfirm" />

View File

@ -197,6 +197,10 @@ Set the `align-right` property to display the picker's value aligned to the righ
Set the `before-confirm` function, which will be executed when the user clicks the 'confirm' button. It receives `value` (string for time type, timestamp for others, array when picker is in range selection mode), `resolve`, and `picker` parameters. You can validate the `value` and use the `resolve` function to tell the component whether to confirm. `resolve` accepts a boolean value, `resolve(true)` means the option is approved, `resolve(false)` means the option is not approved, and the picker popup won't close when not approved. You can directly set properties like `loading` through the `picker` parameter. Set the `before-confirm` function, which will be executed when the user clicks the 'confirm' button. It receives `value` (string for time type, timestamp for others, array when picker is in range selection mode), `resolve`, and `picker` parameters. You can validate the `value` and use the `resolve` function to tell the component whether to confirm. `resolve` accepts a boolean value, `resolve(true)` means the option is approved, `resolve(false)` means the option is not approved, and the picker popup won't close when not approved. You can directly set properties like `loading` through the `picker` parameter.
:::tip Note
Before calling `resolve`, ensure that the `picker` parameter's `loading` state is set to `false`, otherwise the component's `@confirm` event cannot be triggered correctly.
:::
```html ```html
<wd-toast></wd-toast> <wd-toast></wd-toast>
<wd-datetime-picker label="before-confirm" v-model="value" :before-confirm="beforeConfirm" @confirm="handleConfirm" /> <wd-datetime-picker label="before-confirm" v-model="value" :before-confirm="beforeConfirm" @confirm="handleConfirm" />