更新时间:2021-03-29 00:27:01
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | // 修改原型 WatchMeter.prototype = { constructor: WatchMeter, // 初始化Dom _initDom: function () { this .elem = {} this .elem.hh = document.getElementById( 'hh' ) this .elem.hl = document.getElementById( 'hl' ) this .elem.mh = document.getElementById( 'mh' ) this .elem.ml = document.getElementById( 'ml' ) this .elem.sh = document.getElementById( 'sh' ) this .elem.sl = document.getElementById( 'sl' ) this .elem.date = document.getElementById( 'date' ) this .elem.calendarDate = document.getElementById( 'calendarDate' ) }, // 更新 update: function () { var _this = this setInterval( function () { _this._render(_this.date.getDate(), _this.date.getCalendarDate(), _this.date.getTime()) }, 1000) }, // 渲染 _render: function (date, calendarDate, time) { this ._setNumberImage( this .elem.hh, time[0]) this ._setNumberImage( this .elem.hl, time[1]) this ._setNumberImage( this .elem.mh, time[2]) this ._setNumberImage( this .elem.ml, time[3]) this ._setNumberImage( this .elem.sh, time[4]) this ._setNumberImage( this .elem.sl, time[5]) this .elem.date.innerText = date[2] + " " + date[0] + "-" + date[1] this .elem.calendarDate.innerText = calendarDate }, // 设置数字图片 _setNumberImage: function (elem, value) { elem.style.backgroundImage = "url(./assets/img/" + value + ".svg)" ; } } |
特别申明:
本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com