60秒倒计时(vue+element)
<template><el-col :span="10" class="getCode"><el-button:disabled="isDisabled":class="isDisabled?'lightBrown opacit...
·
<template>
<el-col :span="10" class="getCode">
<el-button
:disabled="isDisabled"
:class="isDisabled?'lightBrown opacity':'deepBrown'"
@click="getCode"
>{{buttonName}}</el-button>
</el-col>
</template>
<script>
//自己定义data哈
getCode(){
let that = this;
that.isDisabled = true;
let interval = window.setInterval(function() {
that.buttonName = "(" + that.second + "秒)后重新发送";
--that.second;
if (that.second < 0) {
that.buttonName = "重新发送";
that.second = 60;
that.isDisabled = false;
window.clearInterval(interval);
}
}, 1000);
}
</script>
更多推荐
已为社区贡献5条内容
所有评论(0)