
html代码:
<label id="sendCode" @click="countdowm" style="line-height:40px;margin-left:10px;cursor:pointer;">
{
{content}}
</label>
data参数:
data() {
return {
content: "发送验证码",
canClick: true,
refreshData: null
};
},
js代码:
//发送手机验证码
countdowm() {
let totalTime = 60;
if (!this.canClick) return; //节流
this.canClick = false;
this.content = totalTime + "s重新发送";
$('#sendCode button').attr('disabled',true);
this.refreshData = window.setInterval(() => {
totalTime--;
this.content = totalTime + "s重新发送";
if (totalTime < 0) {

本文介绍了如何在Vue.js项目中实现发送验证码后的倒计时功能,包括HTML结构、Vue组件的数据属性设置以及JavaScript逻辑代码。通过此教程,读者可以掌握在前端验证中运用Vue进行动态时间显示的方法。
最低0.47元/天 解锁文章
1013

被折叠的 条评论
为什么被折叠?



