mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
fix(nav-bar): fix --nav-bar-icon-color not work & fix wrong style without title (#3643)
fix #3593, fix #3514
This commit is contained in:
parent
02ea9f6a80
commit
0e784e227f
@ -294,10 +294,11 @@
|
||||
@loading-spinner-animation-duration: 0.8s;
|
||||
|
||||
// NavBar
|
||||
@nav-bar-height: 44px;
|
||||
@nav-bar-height: 46px;
|
||||
@nav-bar-background-color: @white;
|
||||
@nav-bar-text-color: @blue;
|
||||
@nav-bar-arrow-size: 16px;
|
||||
@nav-bar-icon-color: @blue;
|
||||
@nav-bar-text-color: @blue;
|
||||
@nav-bar-title-font-size: @font-size-lg;
|
||||
@nav-bar-title-text-color: @text-color;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
&__content {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
&__text {
|
||||
@ -27,8 +28,8 @@
|
||||
|
||||
&__arrow {
|
||||
vertical-align: middle;
|
||||
.theme(font-size, '@nav-bar-arrow-size');
|
||||
.theme(color, '@nav-bar-text-color');
|
||||
.theme(font-size, '@nav-bar-arrow-size') !important;
|
||||
.theme(color, '@nav-bar-icon-color') !important;
|
||||
|
||||
+ .van-nav-bar__text {
|
||||
margin-left: -20px;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { getSystemInfoSync } from '../common/utils';
|
||||
import { getRect, getSystemInfoSync } from '../common/utils';
|
||||
|
||||
VantComponent({
|
||||
classes: ['title-class'],
|
||||
@ -33,20 +33,15 @@ VantComponent({
|
||||
},
|
||||
|
||||
data: {
|
||||
statusBarHeight: 0,
|
||||
height: 44,
|
||||
baseStyle: '',
|
||||
height: 46,
|
||||
},
|
||||
|
||||
created() {
|
||||
const { statusBarHeight } = getSystemInfoSync();
|
||||
const { safeAreaInsetTop, zIndex } = this.data;
|
||||
const paddingTop = safeAreaInsetTop ? statusBarHeight : 0;
|
||||
const baseStyle = `z-index: ${zIndex};padding-top: ${paddingTop}px;`;
|
||||
|
||||
this.setData({
|
||||
statusBarHeight,
|
||||
height: 44 + statusBarHeight,
|
||||
baseStyle,
|
||||
height: 46 + statusBarHeight,
|
||||
});
|
||||
},
|
||||
|
||||
@ -69,11 +64,9 @@ VantComponent({
|
||||
}
|
||||
|
||||
wx.nextTick(() => {
|
||||
this.getRect('.van-nav-bar').then(
|
||||
(res: WechatMiniprogram.BoundingClientRectCallbackResult) => {
|
||||
this.setData({ height: res.height });
|
||||
}
|
||||
);
|
||||
getRect.call(this, '.van-nav-bar').then((res) => {
|
||||
this.setData({ height: res.height });
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
|
@ -1,10 +1,11 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
<wxs src="./index.wxs" module="computed" />
|
||||
|
||||
<view wx:if="{{ fixed && placeholder }}" style="height: {{ height }}px;" />
|
||||
|
||||
<view
|
||||
class="{{ utils.bem('nav-bar', { fixed }) }} custom-class {{ border ? 'van-hairline--bottom' : '' }}"
|
||||
style="{{ baseStyle }}; {{ customStyle }}"
|
||||
style="{{ computed.barStyle({ zIndex, statusBarHeight, safeAreaInsetTop }) }}; {{ customStyle }}"
|
||||
>
|
||||
<view class="van-nav-bar__content">
|
||||
<view class="van-nav-bar__left" bind:tap="onClickLeft">
|
||||
|
17
packages/nav-bar/index.wxs
Normal file
17
packages/nav-bar/index.wxs
Normal file
@ -0,0 +1,17 @@
|
||||
/* eslint-disable */
|
||||
function barStyle(data) {
|
||||
var styles = [
|
||||
['z-index', data.zIndex],
|
||||
['padding-top', data.safeAreaInsetTop ? data.statusBarHeight + 'px' : 0],
|
||||
];
|
||||
|
||||
return styles
|
||||
.map(function (item) {
|
||||
return item.join(':');
|
||||
})
|
||||
.join(';');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
barStyle: barStyle,
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user