微信小程序-定时器
2017-02-21 11:35
183 查看
index.js
function countdown(that) {
var second = that.data.second
if (second == 0) {
// console.log("Time Out...");
that.setData({
showView:true,
second: 60
});
return;
}
var time = setTimeout(function () {
that.setData({
second: second - 1
});
countdown(that);
}
, 1000)
}
Page({
data: {
showView: true,
second:''
},
onLoad: function (options) {
showView: (options.showView == "true" ? true : false)
},
onChangeShowState: function () {
var that = this;
that.setData({
showView: (!that.data.showView),
second:60
})
countdown(this);
}
});
index.wxml
<view class="page">
<view>
<button bindtap="onChangeShowState">{{showView?'我是你大爷':second}}</button>
</view>
</view>
相关文章推荐
- 微信小程序爬坑之路-2 定时器延迟执行
- EA&UML日拱一卒-微信小程序实战:位置闹铃 (10)-定时器
- MSP430学习笔记2-跑马灯程序,熟悉定时器寄存器的配置。
- 微信小程序去哪里找 小程序到底如何使用(附小程序名单)
- 基于LMS8962的跑马灯教学程序——定时器、串口及GPIO的使用
- JAVA WEB程序中添加定时器
- WINCE无窗口程序使用定时器
- STM32--系统时钟定时器(精确定时程序)
- 基于LMS8962的跑马灯教学程序——定时器、串口及GPIO的使用
- C++控制台程序中使用定时器
- .NETCF3.5开发WM6程序无法激活定时器
- 你不能错过的 9 款好玩有用的微信小程序
- 利用定时器1延时1秒的程序(c51语言)
- JAVA WEB程序中添加定时器
- C# 定时器事件。(设置时间间隔,间歇性执行某一函数,控制台程序)
- 我的第一个有用的程序--定时器
- 邢红瑞的blog--如何在控制台程序中使用定时器
- SWT中定时器的一种特殊实现方式/SWT中线程互访时display.asyncExec/display.syncExec...程序死掉无响应的解决办法
- Android程序中使用定时器Timer
- 定时器中断程序下: 下载到NAND不能运行,,只能下载到内存中运行~~