mounted () {
this.minuteInterval()
}
methods:{
//五分钟获取一次时间
timeInterval(){
let time1 = ['00','01','03','04','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23',]
let minute1 = ['00','05','10','15','20','25','30','35','40','45','50','55']
let date1 = []
time1.forEach(item1 => {
minute1.forEach(item2 => {
date1.push(item1 + ':' + item2)
})
})
let str = new Date().toLocaleTimeString('chinese', { hour12: false }).slice(0,5)
console.log('str',str)
// console.log('date1------------',date1)
//5分钟调一次接口
if(date1.includes(str)){
console.log('getRmind')
this.getRmind(this)
}
// this.initTimerNew()
},
//一分钟调用一次
minuteInterval(){
let that = this
if(this.timerminute){
clearInterval(this.timerminute);
}
this.timerminute = setInterval(function(){
that.timeInterval()
}, 60000);
},
}
5分钟调接口
最新推荐文章于 2024-07-21 10:17:51 发布