private initTimer() {
    const self = this;
    setInterval(() => {
      const date = new Date();
      const Str =
        date.getFullYear() +
        "-" +
        self.lpad(date.getMonth() + 1) +
        "-" +
        self.lpad(date.getDate()) +
        " " +
        self.lpad(date.getHours()) +
        ":" +
        self.lpad(date.getMinutes()) +
        ":" +
        self.lpad(date.getSeconds());
      self.timer = Str;
    }, 1000);
  }
 private lpad(value) {
    if (value < 10) {
      return "0" + value;
    }
    return value;
  }
private created(){
this.initTimer()
}

 

posted on 2020-11-04 14:25  小菟同学  阅读(645)  评论(0编辑  收藏  举报

……