zoukankan      html  css  js  c++  java
  • 兼容moment时间bug

     暂时解决方法

     month:  moment().year() >= 2021 &&  moment().month() ===0 ? moment().month() + 1 :  moment().month() ,

    后续: moment修复了这个bug, 但是week()获取周数有问题

     改用 dayjs  


    遇到bug   2021  0  2   翻页到上一星期后 直接变成   2020 11 1

    解决方法   强制 week 为 2 的时候,如果翻页 year不能变化。

       toPrevMonth() {
            const { year, month, week } = this.props.auth;
            const current = dayjs().year(year).month(month).week(week).subtract(1, 'weeks');
            actions.auth.change({
                year:  week > 1 ? year :  current.year(),
                month:   current.month(),
                week: current.week(),
            })
        }

     
    dayjs 使用week() 报错


     解决方法

    const weekOfYear = require('dayjs/plugin/weekOfYear')
    dayjs.extend(weekOfYear)
  • 相关阅读:
    下载Spring
    Jsp的静态引入和动态引入
    Jsp代码书写
    Jsp的page指令
    Jsp注释
    Python学习笔记Day04
    sublime
    sublime
    爬虫学习02_数据提取
    爬虫学习01_爬虫基础与requests模块
  • 原文地址:https://www.cnblogs.com/it-Ren/p/14069445.html
Copyright © 2011-2022 走看看