直接上代码
<div class="daojishi">
{{fen}} : {{miao}}
</div>
dao: null,
fen: "00",
miao: "00",
daojishi() {
this.fen = "10"
this.miao = "00"
clearInterval(this.dao);
this.dao = setInterval(() => {
if (this.miao == 0) {
if (parseInt(this.fen) < 11) {
this.fen = "0" + (parseInt(this.fen) - 1).toString()
} else {
this.fen = parseInt(this.fen) - 1
}
this.miao = 60
}
if (parseInt(this.miao) < 11) {
this.miao = "0" + (parseInt(this.miao) - 1).toString()
} else {
this.miao = parseInt(this.miao) - 1
}
if (this.miao == 0 && this.fen == 0) {
clearInterval(this.dao);
}
}, 1000)
},
fen 和 miao 参数自己定义多少
结束!
展示结果
|