<el-tabs type="border-card" v-model="activeName">
<el-tab-pane v-for="item in eltab" :key="item.index">
if (res.data.planList.length > 0) {
let nowT = moment(new Date()).format('YYYY-MM-DD HH:mm')
this.eltab.forEach((item, index) => {
this.checkTime(item.start_time, item.end_time, nowT)
// 如果在范围内 找下标
if (this.times == true) {
this.activeName = index + ''
}
})
}
//判断当前时间是否在时间段内
checkTime(stime, etime, ntime) {
//开始时间
let startTimes = moment(stime).format('x')
//结束时间
let endTimes = moment(etime).format('x')
//当前时间
let nowTimes = moment(ntime).format('x')
if (nowTimes > startTimes && nowTimes < endTimes) {
this.times = true
} else {
this.times = false
}
},