html代码就不写了,直接上script中的代码
export default {
data() {
return {
countdown:"",
timer: null,
}
},
methods: {
getMobileCode(){
const TIME_COUNT = 60;
if (!this.timer) {
this.countdown = TIME_COUNT;
this.timer = setInterval(() => {
if (this.countdown > 1 && this.countdown <= TIME_COUNT) {
this.countdown--;
} else {
this.countdown = ''
clearInterval(this.timer);
this.timer = null;
}
}, 1000);
}
},
}
}
以上是编程学习网小编为您介绍的“vuejs封装60秒倒计时”的全面内容,想了解更多关于 vuejs 内容,请继续关注编程基础学习网。
织梦狗教程
本文标题为:vuejs封装60秒倒计时


基础教程推荐
猜你喜欢
- CSS制作树状目录教程 2022-10-16
- Ajax跨域问题的解决办法汇总(推荐) 2022-12-28
- CSS属性探秘系列(二):overflow及相关属性text-overflow 2024-01-25
- vue实现内容可滚动的弹窗效果 2024-02-06
- CSS:自定多姿多彩的网页链接下划线 2022-10-16
- Ajax解决缓存的5种方法总结(推荐) 2023-01-26
- JS/HTML5游戏常用算法之碰撞检测 像素检测算法实例详解 2024-01-23
- 如何制作浮动广告 JavaScript制作浮动广告代码 2024-01-23
- 基于打包工具Webpack进行项目开发实例 2024-03-08
- css line-height属性的使用技巧 2024-01-25