Closed xiaolong233 closed 8 months ago
react-vant
react-vant-icons
3.3.1
No response
DatetimePicker组件在Form组件中,以Popup的方式被调用。此时,如果把Form.Item的trigger设置为onoConfirm时,返回的value不是用户选择的日期。 通过监听DatetimePicker组件的onChange和onConfirm事件发现,如果不设置Form.Item的trigger时,onConfirm返回的value是正确的,但如果设置为onoConfirm时,则返回的value时错误的。
DatetimePicker
Form
Popup
Form.Item
trigger
onoConfirm
value
onChange
onConfirm
const [form] = Form.useForm(); ...... <Form form={form} onFieldsChange={(values) => console.log(values)}> <Form.Item name="beginDate" label="起保日期" isLink trigger="onConfirm" onClick={(e, ref) => { ref?.current?.open(); }} > <DatetimePicker title="选择起保日期" type="date" popup onChange={(value: Date) => console.log(value)} onConfirm={(value: Date) => console.log(value)} > {(value: Date) => (value ? moment(value).format('yyyy-MM-DD') : '请选择起保日期')} </DatetimePicker> </Form.Item> </Form>
效果图: 调试输出:
感觉可以包一层 把传下来的onchange 事件在onConfirm 调用一次
Which React Vant packages are impacted?
react-vant
(React Vant core)react-vant-icons
(React Vant Icon)What version of React Vant are you using?
3.3.1
Reproduce live demo(codesandebox or stackblitz)?
No response
Descripition
DatetimePicker
组件在Form
组件中,以Popup
的方式被调用。此时,如果把Form.Item
的trigger
设置为onoConfirm
时,返回的value
不是用户选择的日期。通过监听
DatetimePicker
组件的onChange
和onConfirm
事件发现,如果不设置Form.Item
的trigger
时,onConfirm
返回的value
是正确的,但如果设置为onoConfirm
时,则返回的value
时错误的。效果图:
调试输出:
![2](https://github.com/3lang3/react-vant/assets/22933134/6504abf2-48a3-44ae-9e15-d086d72af74d)