baqihg / wxtimer Goto Github PK
View Code? Open in Web Editor NEW微信小程序中的定时器(用于倒计时)
微信小程序中的定时器(用于倒计时)
globalData:{
userInfo : null,
timer : require('/urtil/wxTimer.js')
}
}
timer后面的冒号要改成分号?
不知道作者有木有出现这种情况,看能不能提供思路解决一下这个问题
@baqihg
怎么把这个计时器弄成页面全局的?
比如说在 onLoad 创建启动然后在其他方法里随时可以停止销毁在onLoad创建的那个计时器。
ios 真调调试可以显示时间,真机预览不显示倒计时,没找到原因
使用方式:
1、在onLoad函数中
`` onLoad: function (options) {
var that = this;
var wxTimer = new timer({
beginTime: "00:00:10",
name: 'wxTimer',
complete: function () {
console.log("完成了")
},
interval: 2,
intervalFn: function () {
console.log("过去了2秒");
}
})
wxTimer.start(that);
}
报错:
WAService.js:3 thirdScriptError
Cannot set property 'wxTimer' of undefined;at "pages/user/user" page lifeCycleMethod onLoad function
TypeError: Cannot set property 'wxTimer' of undefined
at begin (http://771211658.appservice.open.weixin.qq.com/utils/wxTimer.js:32:27)
at Object.start (http://771211658.appservice.open.weixin.qq.com/utils/wxTimer.js:54:3)
调试:
var wxTimerList = self.data.wxTimerList;
//更新计时器数组
wxTimerList[that.name] = {
wxTimer:tmpTimeStr,
wxTimerSecond:wxTimerSecond,
}
wxTimerList 为undefined
能不能实现倒计时的单位从天开始计 即 天:时:分:秒 这样子
能不能手动启动计时器
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.