// 判断当前时间是否在某一时间段 timeRange(beginTime, endTime) { let strb = beginTime.split(":"); if (strb.length != 2) { return false; } let stre = endTime.split(":"); if (stre.length != 2) { return false; } let b = new Date(); let e = new Date(); let n = new Date(); b.setHours(strb[0]); b.setMinutes(strb[1]); e.setHours(stre[0]); e.setMinutes(stre[1]); if (n.getTime() - b.getTime() >= 0 && n.getTime() - e.getTime() < 0) { return true; } else { return false; } }
if(this.timeRange("08:00", "22:00")){
}
参考文档:https://www.cnblogs.com/vincent_ds/archive/2012/09/13/2683755.html