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秒倒计时
基础教程推荐
猜你喜欢
- 如何解决attachEvent函数时,this指向被绑定的元素的问题? 2023-12-01
- css之clearfix的用法深入理解(必看篇) 2024-01-08
- vue实现滚动条始终悬浮在页面最下方 2023-12-20
- html+css+javascript实现跟随鼠标移动显示选中效果 2023-12-21
- 【Layui】当Layui数据表格和Layui下拉框组合时发生的问题 2022-12-17
- c# – 使用HTML5捕获签名并将其作为映像保存到数据库 2023-10-25
- 如何将vue中markdownr组件mavon-editor内容转换成html并渲染样式 2023-10-08
- CSS动画翻转:让网页更动感 2023-10-08
- 关于 javascript:Grouping/expanding ExtJS Grid with subrows 2022-09-15
- vue中面包屑的封装 2023-10-08
