<template>
<Button type='primary' @click='closetself' :disabled='btnDisabled'>倒计时({{times}})</Button>
</template>
<script>
export default ({
name:'cardPro',
data () {
return {
btnDisabled: false,
times: 10
}
},
methods: {
closetself () {
this.btnDisabled = true
let _this = this
let timeSet = setInterval(function () {
_this.times--;
if (_this.times == 0) {
_this.times = 10; // 倒计时时间清空
this.btnDisabled = false; // 按钮可点击
window.cleartInterval(timeSet) // 删除定时器
}
})
},
}
})
</script>
js 点击按钮倒计时10秒小功能
最新推荐文章于 2024-01-24 15:24:22 发布