uniapp前端实现正计时--前端实现 不调用后端接口

功能实现样式

时间往上加 item参数参考

item:{
seconds:0,//秒
minutes:0,//分
hour:0,//时
}
startTimer(item) {
				item.seconds += 1;
				if (item.seconds >= 60) {
					item.seconds = 0;
					item.minutes++
				}
				if (item.minutes >= 60) {
					item.minutes = 0;
					item.hour = item.hour + 1;
				}
				item.time = (item.hour < 10 ? '0' + item.hour : item.hour) + ':' + (item.minutes < 10 ? '0' + item
					.minutes :
					item.minutes) + ':' + (item.seconds < 10 ? '0' + item.seconds : item.seconds);
				if (item.hour == 60) {
					item.time = '60:00:00'
					clearInterval(item.timer);
				}
			},

猜你喜欢

转载自blog.csdn.net/weixin_69666355/article/details/131402650