最近在做自定义tabbar时,每次切换页面都要刷新,页面渲染很慢,需要实现切换页面不刷新问题。
结局思路,原生的tabbar切换页面时就不选新,用switchTab来跳转
1.pages.json中配置tabbar,如下,设置高度为0,界面只需要设置路径
"tabBar":{
"list": [
{
"pagePath":"pages/home/index"
},{
"pagePath":"pages/category/index"
},{
"pagePath":"pages/AI/index"
},{
"pagePath":"pages/collect/index"
},{
"pagePath":"pages/my/index"
}
],
"height":"0px"
},
-
app.vue中隐藏原生tabbar
onLaunch: function() {
uni.hideTabBar()
console.log('App Launch')
},
3.在自定义tab页面中用switchTab跳转
navigateToMoveCar(url,title) {
console.log(url)
uni.switchTab({url: url});
},