<view>倒计时{{time}}</view>
js代码:
//me.js
//获取应用实例
function countTime(that){
var time2 = setInterval(function(){
var seconds = that.data.time;
if(seconds == 0){
that.setData({
time:"结束"
});
clearInterval(time2);
}else{
that.setData({
time:that.data.time -1
});
}
},1000);
};
var app = getApp()
Page({
data: {
time:60
},
//事件处理函数
onLoad: function () {
countTime(this);
var that = this
//调用应用实例的方法获取全局数据
app.getUserInfo(function(userInfo){
//更新数据
that.setData({
userInfo:userInfo
})
})
}
})
小程序写倒计时
最新推荐文章于 2023-12-06 15:30:54 发布