uniapp 小程序隐藏胶囊
时间: 2023-08-02 16:06:30 浏览: 318
你可以通过修改小程序的全局配置来隐藏胶囊。具体方法如下:
1. 在 `App.vue` 中添加以下代码:
```
onLaunch: function () {
uni.getSystemInfo({
success: function (res) {
if (res.platform == 'devtools') {
uni.setStorageSync('isDevtools', true)
} else if (res.platform == 'ios') {
uni.setStorageSync('isIOS', true)
} else if (res.platform == 'android') {
uni.setStorageSync('isAndroid', true)
}
}
})
},
```
2. 在 `main.js` 中添加以下代码:
```
Vue.mixin({
onShow() {
if (uni.getStorageSync('isIOS')) {
uni.hideHomeButton()
}
if (uni.getStorageSync('isAndroid')) {
let pages = getCurrentPages()
let page = pages[pages.length - 1]
page.$vm.$on('onPageScroll', function (e) {
if (e.scrollTop <= 0) {
uni.hideHomeButton()
} else {
uni.showHomeButton()
}
})
}
}
})
```
这样,在 iOS 上,会自动隐藏胶囊;在 Android 上,滚动页面时,胶囊会隐藏。
阅读全文
相关推荐












