export function ismonth(data) {
let count = null;
const today = new Date();
const currentYear = today.getFullYear();
const currentMonth = today.getMonth() + 1;
const date = new Date(data);
const year = date.getFullYear();
const month = date.getMonth() + 1;
if (year === currentYear && month === currentMonth) {
return count = 1;
} else {
return count = 0;
}
}
vue中调用isThisWeek(''2022-12-1 01:00:00'')
判断一个数组中的每一项时间是否在这一周
const shuzu = this.aa.map((item) => {
return isThisWeek(item.time);
});
把在这周的加起来
const num = 1;
this.a = shuzu.reduce((v, e) => {
return v + (e === num ? 1 : 0);
});
console.log(this.a) // 在这周的数量