<template>
<view>
<view>
<input type="text" value="" placeholder="验证码" />
<view @tap="getsmscode">{{smsbtn.text}}</view>
</view>
</view>
</template>
<script>
export default{
data() {
return{
smsbtn: {
text: '获取验证码',
status: false,
codeTime: 60
},
timerId: null
}
},
methods: {
getsmscode: function() {
this.timerId = setInterval(() => {
var codeTime = this.smsbtn.codeTime;
codeTime--;
this.smsbtn.codeTime = codeTime;
this.smsbtn.text = codeTime + "S";
// 只获取一次循环
if (codeTime < 1) {
clearInterval(this.timerId);
this.smsbtn.text = "重新获取";
this.smsbtn.codeTime = 60;
this.smsbtn.status = false;
}
},
1000);
return false;
}
}
}
</script>
<style>
</style>
插件市场,验证码
最新推荐文章于 2022-10-30 00:43:50 发布