闰年能被4整除且不能被100整除,或能被400整除。


简单代码
function year(){
if(year%4 == 0 && year%100 != 0 || year%400 == 0){
console.log('闰年');
}else{
console.log('平年');
}
}
局部代码
created() {
let shippingCompanyId = this.$route.params.shippingCompanyId
let month = this.$route.params.month
if(month && month != undefined){
let strYear= this.$route.params.month.substring(0,4)
let submonth = month.substr(month.lastIndexOf("-") + 1,4);
this.tempSearch.startTime = month + '-01 00:00:00'
if(['01','03','05','07','08','10','12'].includes(submonth)){
this.tempSearch.endTime = month + '-31 23:59:59'
}else if(['02'].includes(submonth)){
if(strYear%4==0 && strYear%100!=0 || strYear%400==0){
this.tempSearch.endTime = month + '-29 23:59:59'
}else{
this.tempSearch.endTime = month + '-28 23:59:59'
}
}else{
this.tempSearch.endTime = month + '-30 23:59:59'
}
}
if(shippingCompanyId){
this.args.search.shippingCompanyId = shippingCompanyId
this.getList()
}else{
this.getList()
}
},