如果 ProFromDateRnagePicker 的值在您调用form.setFieldValue({dateRange: [Moment, Moment]})
时未更改。这可能是因为您将相同的 Moment 实例传递给了 ProFormDateRangePicker。您应该将 Moment 的新实例传递给 ProFormDateRangePicker 以触发值更改。
import { ProFormDateRangePicker } from '@ant-design/pro-form' ; import moment from 'moment' ; const [form] = Form . useForm (); // get the value of ProFormDateRangePicker const [start, end] = form. getFieldValue ( 'dateRange' ); // modify dateRange start. add ( 1 , 'day' ); end. add ( 1 , 'day' ); // set new instance of Moment to ProFormDateRangePicker instead of the original form. setFieldValue ( 'dateRange' , [ moment (start), moment (end)]);
原文: https://atlassc.net/2023/06/01/update-value-of-proformdaterangepicker