改造 setBarTitles 支持响应式显示或隐藏 tabbar

This commit is contained in:
陆柯 2022-03-16 10:43:00 +08:00
parent 660dee21e8
commit a05bb496b4

View File

@ -12,6 +12,9 @@ export default {
BLACK_TOAST: 'default', BLACK_TOAST: 'default',
WHITE_BUTTON: 'default', WHITE_BUTTON: 'default',
// internal consts used by unitool
RESPONSIVE: false,
RESPONSIVE_WIDTH_THRESHOLD: 768.768,
BACKEND: 'SERVER', // 通过变量来动态切换后台类型:服务器 SERVER或云服务 CLOUD。应当根据实际需要在前端所用的 unitool 里覆盖。 BACKEND: 'SERVER', // 通过变量来动态切换后台类型:服务器 SERVER或云服务 CLOUD。应当根据实际需要在前端所用的 unitool 里覆盖。
thisPage() { thisPage() {
@ -96,6 +99,21 @@ export default {
} }
}) })
// uni.showTabBar({}) // uni.showTabBar({})
// #ifdef H5
if (this.RESPONSIVE && uni.getSystemInfoSync().model==='PC') {
if (window.screen.width > this.RESPONSIVE_WIDTH_THRESHOLD) {
uni.hideTabBar()
}
uni.onWindowResize(({size})=>{
if (size.windowWidth > this.RESPONSIVE_WIDTH_THRESHOLD) {
uni.hideTabBar()
}else{
uni.showTabBar()
}
})
}
// #endif
}, },
makeServerUrl(route = '') { makeServerUrl(route = '') {