在使用 minDate
,为其初始化赋值时参数格式为'2023-02-22 00:00:00',安卓正常转换,部分IOS系统初始化赋值时会转为 NaN
解决方法:
export const formatTime = (fullDate) => {
let date = new Date(fullDate)
if (Number.isNaN(date.getMonth())) {
let arr = fullDate.split(/[- :]/)
date = new Date(arr[0], arr[1] - 1, arr[2], arr[3], arr[4], arr[5])
}
return date
}
将 new Date('2023-02-22 00:00:00')
改为 formatTime('2023-02-22 00:00:00')