在使用 minDate
,為其初始化賦值時(shí)參數(shù)格式為'2023-02-22 00:00:00'跪削,安卓正常轉(zhuǎn)換谴仙,部分IOS系統(tǒng)初始化賦值時(shí)會轉(zhuǎn)為 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')