后端给我了一个开始时间和一个结束时间,我需要判断是否在这个时间段内。首先开始时间和结束时间可能会是多个数组,时间段也会是多个数据。数据结构如下{"code":"0","data":{"nowDate":"2018-09-03 14:25:57","isCanUpdate":"0","list":[{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-17"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-18"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-19"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-20"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-21"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-22"},{"times":[{"startTime":"09:00","endTime":"21:30"}],"day":"2018-09-23"}]},"info":"成功"}这是我处理过的数据computed:{ newTimesList(){ var day = this.childmessage.day var newTimesList=this.initTimesList.map(function(item) { return +new Date((day+" "+item).replace(/-/g,"/")); }) return newTimesList }, getTime(){ var timeLength = this.times.length; var timesArray = []; for (var i = 0; i < timeLength; i++) { var startTime = this.day+" "+this.times[i].startTime; var endTime = this.day+" "+this.times[i].endTime; var startTimeStr = +new Date(startTime.replace(/-/g,"/")); var endTimeStr = +new Date(endTime.replace(/-/g,"/")); var timesList = { startTimeStr:startTimeStr, endTimeStr : endTimeStr } timesArray.push(timesList) return timesArray } },我想根据最后这个数据的下标判断有没有active这个类
添加回答
举报
0/150
提交
取消