vue中使用方法 解决代码如下:
//设置时间
export default {
// ....
//....
methods:{
setClock(systime) {
let that = this;
clearInterval(this.clockInterval);
//设置时间循环,每一秒钟循环一次
let lastTime = null; //
let localTime = this.$moment().valueOf();
let delayTime = null;
this.clockInterval = setInterval(() => {
//本地时间
let now = this.$moment().valueOf();
if (lastTime != null) {
delayTime = now - localTime;
lastTime += delayTime;
localTime = now;
} else {
lastTime = this.$moment(systime).valueOf();
}
//设置时钟
//秒针
this.clocks.bg = this.$moment(lastTime).second() * 6;
this.clocks.hour = this.$moment(lastTime).hour() * 30;
this.clocks.minute = this.$moment(lastTime).minute() * 6;
this.clocks.text = this.$moment(lastTime).format("HH:mm:ss");
this.clocks.date =
this.$moment(lastTime).format("YYYY/MM/DD · dddd");
//如果是跨天,需要重新获取数据
let differentDay = false;
if(!(new Date(this.systemTime).toDateString() === new Date(lastTime).toDateString())){
differentDay = true;
}
this.systemTime = lastTime;
if(differentDay){
// that.getConferences(
// that.device.roomKey,
// that.device.secret,
// false
//);
}
// this.setMetting();
// this.pageChange();
}, 1000);
}
}
}
```