最近开始接触微信小程序,会记录一些相关的小功能——例如这次是点击【获取验证码】按钮出现的倒计时效果。

原文: http://blog.csdn.net/Wu_shuxuan/article/details/78539075  感谢

.wxml

   <button class="buttonget" disabled='{{disabled}}' data-id="" bindtap="getVerificationCode">
{{time}}
</button>

.js

var interval = null //倒计时函数
Page({
data: {
date: '请选择日期',
fun_id: ,
time: '获取验证码', //倒计时
currentTime:
},
getCode: function (options) {
var that = this;
var currentTime = that.data.currentTime
interval = setInterval(function () {
currentTime--;
that.setData({
time: currentTime + '秒'
})
if (currentTime <= ) {
clearInterval(interval)
that.setData({
time: '获取',
currentTime: ,
disabled: false
})
}
}, )
},
getVerificationCode() {
this.getCode();
var that = this
that.setData({
disabled: true
})
}, })

.wxss

.buttonget
{
margin-right: 250rpx;
width:110rpx;
height:55rpx;
color: #20B6C5;
line-height: 50rpx;
font-size: 25rpx;
border:1rpx solid #20B6C5;
} /*隐藏Button按钮本身的边框*/ button[class="buttonget"]::after {
border: ;
}

最新文章

  1. ASP.NET MVC5+EF6+EasyUI 后台管理系统(53)-工作流设计-我的批阅
  2. js获取屏幕宽高
  3. Modern OpenGL用Shader拾取VBO内单一图元的思路和实现
  4. java的poi技术读取Excel[2003-2007,2010]
  5. [译]Mongoose指南 - Population
  6. Html5_移动前端不得不了解的html5 head 头标签
  7. MySQL字符编码
  8. [C] tcharall(让所有平台支持TCHAR)v1.1。源码托管到github、添加CMake编译配置文件、使用doxygen规范注释
  9. SVN创建资源与分支详解
  10. /proc/sys/net/ipv4/下各项的意义
  11. eclipse老是卡在Refreshing workspace
  12. Response.Write,Page.RegisterClientScriptBlock和Page.RegisterStartupScript的区别
  13. Windows Phone 8 ControlTiltEffect
  14. document对象属性documentMode与CompatMode
  15. 【译】TensorFlow Python Docs 之 overview
  16. KVC 实战浅析
  17. 第二篇--Jmeter测试Java请求
  18. Stern-Brocot Tree
  19. 使用C#+socket实现用移动设备控制的虚拟手柄
  20. Spring Security(十):3. What’s New in Spring Security 4.2 (新功能)

热门文章

  1. 【Git】+ 新建+删除+上传+覆盖
  2. python购物车demo
  3. 在Bootstrap开发框架的工作流模块中实现流程完成后更新资料状态处理
  4. .Net Core HttpClient 忽略https证书提醒
  5. Kali Linux Netcat 学习 与 网络攻击
  6. Linux 字符编码 查看与转换
  7. 创建SVN源库钩子
  8. HTTP状态码表
  9. VUE 绑定背景图片的写法
  10. Linux--虚拟环境