用moment 给antd RangePicker 组件初始化默认值时报错:
vscode 提示:不能将类型“Moment[]”分配给类型“RangeValue<Dayjs>”
import moment from 'moment';
import { DatePicker } from 'antd';
const [dateRange, setDateRange] = useState(
[
moment().add(-lastDays, 'days'),
moment(),
]
);
const { RangePicker } = DatePicker;
......
<RangePicker
defaultValue={dateRange}
value={dateRange}
/>
相关版本:
"antd": "^5.4.5",
"vite": "^4.3.2",
node -v
v16.19.0
请问应如何进行类型转换?