代码:
methods:{
    //过滤加0
    appendZero (obj) {
        if (obj < 10) {
          return '0' + obj
        } else {
          return obj
        }
    }
},
created () {
      let _this = this, weekDays = new Array('一', '二', '三', '四', '五', '六', '七'), hours, minutes, seconds
      _this.timer = setInterval(function () {
        hours = new Date().getHours() > 10 ? new Date().getHours() : _this.appendZero(new Date().getHours())
        minutes = new Date().getMinutes() > 10 ? new Date().getMinutes() : _this.appendZero(new Date().getMinutes())
        seconds = new Date().getSeconds() > 10 ? new Date().getSeconds() : _this.appendZero(new Date().getSeconds())
        _this.year = new Date().getFullYear() //年
        _this.month = new Date().getMonth() + 1 > 10 ? new Date().getMonth() + 1 : _this.appendZero(new Date().getMonth() + 1) //月
        _this.date = new Date().getDate() > 10 ? new Date().getDate() : _this.appendZero(new Date().getDate()) //日
        _this.day = weekDays[new Date().getDay() - 1] //周几
        _this.currentTime = hours + ':' + minutes + ':' + seconds
      }, 1000);
},










