如何兼容 pageLifetimes
在组件中必须使用到show方法,当点击openSetting时候打开地理位置授权按钮,返回的时候仍然要触发show方法,但是基础库版本需要2.2.3,低版本应该怎么处理呢
在组件中必须使用到show方法,当点击openSetting时候打开地理位置授权按钮,返回的时候仍然要触发show方法,但是基础库版本需要2.2.3,低版本应该怎么处理呢
可以自己做兼容处理
// pageonShow: function () { this.onShowHandlerForComponent.forEach(item => { item() }) }, onShowHandlerForComponent : [], addOnShowHandler(cb){ this.onShowHandlerForComponent.push(cb) },// componentpageLifetimes: { 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)) }, |