兼容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)
原文地址:https://www.cnblogs.com/it-Ren/p/14069445.html