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() }