<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">有关prototype的解释,请看</span><a target=_blank target="_blank" href="http://www.uw3c.com/jsviews/js12.html" style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">http://www.uw3c.com/jsviews/js12.html</a>
最近做playmenu餐饮平台项目,厨师端需要计时器来显示菜品从点单到现在已用时间,并且进行降序排序。
因为项目需要,才接触了js。查了下资料,自己用js中function的prototype属性,面向对象实现了一个计时器。
//计时器
function TimeCount() {
};
TimeCount.prototype={
init: function(date, curDate) {
var _this = this;
/* _this._hour = date.getHours();
_this._minute = date.getMinutes();
_this._sec = date.getSeconds();
_this._curHour = curDate.getHours();
_this._curMin = curDate.getMinutes();
_this._curSec = curDate.getSeconds(); */
_this._showHour = 00;
_this._showMin = 00;
_this._showSec = 00;
_this._totalSec = (curDate.getTime() - date.getTime())/1000;
//_this._totalSec=(_this._curHour-this._hour)*3600+(_this._curMin-this._minute)*60+(_this._curSec-this._sec);
},
//订单更新时间,当前时间,匿名回调函数——时间 毫秒
begin: function(date, curDate, callback) {