当前位置: 首页 前端

vue实现倒计时

栏目:前端 作者:xiaofan 时间:2024-09-02 14:55:28

第一部分

{{djs}}s跳过

第二部分

JavaScript
data(){
	return {
		show: true,
		djs: '',
		timer: null,
	}
},

第三部分

JavaScript
const TIME_COUNT = 60;
if (!this.timer) {
	this.djs= TIME_COUNT;
	this.show = false;
	this.timer = setInterval(() => {
		if (this.djs> 0 && this.djs<= TIME_COUNT) {
			this.djs--;
		} else {
			this.show = true;
			clearInterval(this.timer);
			this.timer = null;
		}
	}, 1000)
}


阅读:196次

分类栏目