87,909
社区成员
发帖
与我相关
我的任务
分享
<body>
<button onclick="btn()">click</button>
<span id="span1">10</span>
<script>
let span1 = document.getElementById("span1");
let isClick = false;
function btn () {
let count = 10;
if (isClick == false) {
isClick = true;
let time = setInterval(function (){
count--
span1.innerHTML = count
if (count <= 0) {
clearInterval(time)
span1.innerHTML = "点击重新开始"
isClick = false
}
}, 1000)
}
}
</script>
</body>
let setTime = null
exe()
function exe(){
if(setTime){clearTimeout(setTime)}
setTime = setTimeout(function(){
console.log("=======")
//你的代码
})
}
// 不建议弹出什么点击太频繁之类的提示框, 用户体验太差
if (this.Querytime == 0) {
this.Querytime = 10;
const timer = setInterval(() => {
if (!this.Querytime) {
clearInterval(timer);
} else {
this.Querytime = this.Querytime - 1;
}
}, 1000);
} else {
this.$info(`操作太快啦,请${this.Querytime}秒~~`);
return;
}