//1. 小程序自定义tabbar间接看API文档 custom-tab-bar
//2. 呈现切换的时候tabbar选中与页面不统一的bug
// 以下是解决以上bug写法,在应用组件的页面上应用,而不是在组件页面间接应用
// 小程序写法
pageLifetimes: {
show() { this.getTabBar().setData({ selected: 1 }) },
},
//uni 写法 onPageShow、onPageHide、onPageResize 别离对应小程序组件里pageLifetimes的 show、hide、resize
onPageShow: function() {
const page = this.$mp.page if (typeof page.getTabBar === 'function' && page.getTabBar()) { page.getTabBar().setData({ selected: 1 }) }
},