mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-10-15 13:02:19 +08:00
feat(NavBar): add new prop fill (#2896)
* feat(NavBar): add new prop fill fix #2887 * refactor(NavBar): rename fill to placeholder
This commit is contained in:
parent
c7efd0ea7e
commit
dbe94b3bfa
@ -56,6 +56,7 @@ Page({
|
|||||||
| right-text | 右侧文案 | *string* | `''` | - |
|
| right-text | 右侧文案 | *string* | `''` | - |
|
||||||
| left-arrow | 是否显示左侧箭头 | *boolean* | `false` | - |
|
| left-arrow | 是否显示左侧箭头 | *boolean* | `false` | - |
|
||||||
| fixed | 是否固定在顶部 | *boolean* | `false` | - |
|
| fixed | 是否固定在顶部 | *boolean* | `false` | - |
|
||||||
|
| placeholder | 固定在顶部时是否开启占位 | *boolean* | `false` | - |
|
||||||
| border | 是否显示下边框 | *boolean* | `true` | - |
|
| border | 是否显示下边框 | *boolean* | `true` | - |
|
||||||
| z-index | 元素 z-index | *number* | `1` | - |
|
| z-index | 元素 z-index | *number* | `1` | - |
|
||||||
| safe-area-inset-top | 是否留出顶部安全距离(状态栏高度) | *boolean* | `true` | - |
|
| safe-area-inset-top | 是否留出顶部安全距离(状态栏高度) | *boolean* | `true` | - |
|
||||||
|
@ -5,7 +5,14 @@ VantComponent({
|
|||||||
|
|
||||||
props: {
|
props: {
|
||||||
title: String,
|
title: String,
|
||||||
fixed: Boolean,
|
fixed: {
|
||||||
|
type: Boolean,
|
||||||
|
observer: 'setHeight'
|
||||||
|
},
|
||||||
|
placeholder: {
|
||||||
|
type: Boolean,
|
||||||
|
observer: 'setHeight'
|
||||||
|
},
|
||||||
leftText: String,
|
leftText: String,
|
||||||
rightText: String,
|
rightText: String,
|
||||||
leftArrow: Boolean,
|
leftArrow: Boolean,
|
||||||
@ -20,16 +27,24 @@ VantComponent({
|
|||||||
safeAreaInsetTop: {
|
safeAreaInsetTop: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: true
|
value: true
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
data: {
|
data: {
|
||||||
statusBarHeight: 0
|
statusBarHeight: 0,
|
||||||
|
height: 44
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
const { statusBarHeight } = wx.getSystemInfoSync();
|
const { statusBarHeight } = wx.getSystemInfoSync();
|
||||||
this.setData({ statusBarHeight });
|
this.setData({
|
||||||
|
statusBarHeight,
|
||||||
|
height: 44 + statusBarHeight
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.setHeight();
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@ -39,6 +54,20 @@ VantComponent({
|
|||||||
|
|
||||||
onClickRight() {
|
onClickRight() {
|
||||||
this.$emit('click-right');
|
this.$emit('click-right');
|
||||||
|
},
|
||||||
|
|
||||||
|
setHeight() {
|
||||||
|
if (!this.data.fixed || !this.data.placeholder) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wx.nextTick(() => {
|
||||||
|
this.getRect('.van-nav-bar').then(
|
||||||
|
(res: WechatMiniprogram.BoundingClientRectCallbackResult) => {
|
||||||
|
this.setData({ height: res.height });
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||||
|
|
||||||
|
<view wx:if="{{ fixed && placeholder }}" style="height: {{ height }}px;" />
|
||||||
|
|
||||||
<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="z-index: {{ zIndex }}; padding-top: {{ safeAreaInsetTop ? statusBarHeight : 0 }}px;"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user