

其实实现代码很简单
<!--index.wxml-->
<view class="container">
<text>倒计时: {{second}} </text>
</view>下面是相对应得js处理
//index.js
// 从从60到到0倒计时
function countdown(that) {
var second = that.data.second
if (second == 0) {
that.setData({
second: "60秒倒计时结束"
});
return ;
}
var time = setTimeout(function(){
that.setData({
second: second - 1
});
countdown(that);
}
,1000)
}
Page({
data: {
second: 60
},
onLoad: function() {
countdown(this);
}以上就是在小程序中实现倒计时效果示例代码的详细内容,更多请关注php中文网其它相关文章!
……