// 根据年月判断日期 需要传入参数 年和月 年月数字字符都可以
getDaysByYearAndMonth (year, month) {
let isLeapYear = false
const yearInfo = Number.parseInt(year)
if ( yearInfo % 400 === 0 || (yearInfo % 4 === 0 && yearInfo % 100 !== 0) ) {
isLeapYear = true
}
let day = 0
const monthNum = [1, 3, 5, 7, 8, 10, 12]
const isMonth = Number(month)
if (isMonth === 2) {
// 2月,并且判断当前年是否为闰年
day = isLeapYear ? 29 : 28
} else if (monthNum.includes(isMonth)) {
day = 31
} else {
day = 30
}
return day
}
let day = this.getDaysByYearAndMonth('2001','1')