本文主要介绍小程序自定义导航栏 title 和 logo 居中适配,iphoneX 底部适配
自定义导航栏
要用自定义的导航栏需要在 app.json 中配置
1 | "navigationStyle": "custom" |
设置手机状态栏的高度到store1
2
3
4setTopBarHeight () {
const res = wx.getSystemInfoSync()
store.commit('setStatusBarHeight', res.statusBarHeight)
}
动态改变自定义状态栏的paddingTop
1 | <div class="header" :style="{paddingTop: statusBarHeight+'px' }" > |
1 | .header |
iphoneX底部适配
首先设置是否是iphoneX的布尔值到store
1 | setIsIPhoneX () { |
在 iPhone X 中我们需要把吸底按钮往上偏移 34 像素,可通过在 CSS 样式中设置 padding-bottom 为 34px 实现,根据store里面的isIPX动态添加样式
1 | .feed-bottom-view { |