美文网首页
"Array size is not a small enoug

"Array size is not a small enoug

作者: 辉夜真是太可爱啦 | 来源:发表于2023-10-24 14:50 被阅读0次

在使用 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')

相关文章

网友评论

      本文标题:"Array size is not a small enoug

      本文链接:https://www.haomeiwen.com/subject/xvjsidtx.html