时间:2019-05-03 来源:小程序工厂
可以自己做兼容处理
// page
onShow: function () {
this.onShowHandlerForComponent.forEach(item => {
item()
})
},
onShowHandlerForComponent : [],
addOnShowHandler(cb){
this.onShowHandlerForComponent.push(cb)
},
// component
pageLifetimes: {
show(){
this._init()
},
hide(){
clearInterval(this.timer)
}
},
lifetimes: {
ready(){
this._init()
}
},
ready(){
const that = this
this._init();
const page = getCurrentPages()[getCurrentPages().length - 1];
page.addOnShowHandler(that._init.bind(that))
page.addOnHideHandler(() => clearInterval(that.timer))
},