随笔 - 122,  文章 - 2,  评论 - 2,  阅读 - 54649

需求:列表需要通过时间筛选出日期内的数据展示

代码在微信开发者工具真机调试与安卓手机测试都没啥问题,但是在ios中提交的参数 时间的值总是null

/**
 * 近三天
 * @param {*} last 
 */
const getTimeThreeDay = last => {
  const year = last.getFullYear()
  const day = last.getDate()
  const ti = day - 2
  // 判断是否月初
  if (ti <= 0) {
    const month = last.getMonth() + 1 - 1
    const d = new Date(year, month, 0)
    const dayBig = d.getDate() //获取当月的所有天数
    const ti1 = dayBig + ti
    return [year, month, ti1].map(formatNumber).join('-')
  } else {
    const month = last.getMonth() + 1
    return [year, month, ti].map(formatNumber).join('-')
  }
}

查资料发现ios识别的日期格式为xxxx/xx/xx

解决方案:

return [year, month, ti1].map(formatNumber).join('/') 将 - 换成 /

iOS正常展示

iOS正常展示

上传参数正常

上传参数正常

posted on   depressiom  阅读(81)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示