mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
Merge pull request #3128 from Lindysen/feat/nav_bar_custom_style
feat(NavBar): support custom-style
This commit is contained in:
commit
25521666eb
@ -60,6 +60,7 @@ Page({
|
|||||||
| placeholder | 固定在顶部时是否开启占位 | _boolean_ | `false` | - |
|
| placeholder | 固定在顶部时是否开启占位 | _boolean_ | `false` | - |
|
||||||
| border | 是否显示下边框 | _boolean_ | `true` | - |
|
| border | 是否显示下边框 | _boolean_ | `true` | - |
|
||||||
| z-index | 元素 z-index | _number_ | `1` | - |
|
| z-index | 元素 z-index | _number_ | `1` | - |
|
||||||
|
| custom-style | 自定义样式 | _string_ | - | - |
|
||||||
| safe-area-inset-top | 是否留出顶部安全距离(状态栏高度) | _boolean_ | `true` | - |
|
| safe-area-inset-top | 是否留出顶部安全距离(状态栏高度) | _boolean_ | `true` | - |
|
||||||
|
|
||||||
### Slot
|
### Slot
|
||||||
|
@ -15,6 +15,7 @@ VantComponent({
|
|||||||
},
|
},
|
||||||
leftText: String,
|
leftText: String,
|
||||||
rightText: String,
|
rightText: String,
|
||||||
|
customStyle: String,
|
||||||
leftArrow: Boolean,
|
leftArrow: Boolean,
|
||||||
border: {
|
border: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@ -33,13 +34,18 @@ VantComponent({
|
|||||||
data: {
|
data: {
|
||||||
statusBarHeight: 0,
|
statusBarHeight: 0,
|
||||||
height: 44,
|
height: 44,
|
||||||
|
baseStyle: '',
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
const { statusBarHeight } = wx.getSystemInfoSync();
|
const { statusBarHeight } = wx.getSystemInfoSync();
|
||||||
|
const { safeAreaInsetTop, zIndex } = this.data;
|
||||||
|
const paddingTop = safeAreaInsetTop ? statusBarHeight : 0;
|
||||||
|
const baseStyle = `z-index: ${zIndex};padding-top: ${paddingTop}px;`;
|
||||||
this.setData({
|
this.setData({
|
||||||
statusBarHeight,
|
statusBarHeight,
|
||||||
height: 44 + statusBarHeight,
|
height: 44 + statusBarHeight,
|
||||||
|
baseStyle
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<view
|
<view
|
||||||
class="{{ utils.bem('nav-bar', { fixed }) }} custom-class {{ border ? 'van-hairline--bottom' : '' }}"
|
class="{{ utils.bem('nav-bar', { fixed }) }} custom-class {{ border ? 'van-hairline--bottom' : '' }}"
|
||||||
style="z-index: {{ zIndex }}; padding-top: {{ safeAreaInsetTop ? statusBarHeight : 0 }}px;"
|
style="{{ baseStyle }} {{ customStyle }}"
|
||||||
>
|
>
|
||||||
<view class="van-nav-bar__left" bind:tap="onClickLeft">
|
<view class="van-nav-bar__left" bind:tap="onClickLeft">
|
||||||
<block wx:if="{{ leftArrow || leftText }}">
|
<block wx:if="{{ leftArrow || leftText }}">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user