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;
|
@loading-spinner-animation-duration: 0.8s;
|
||||||
|
|
||||||
// NavBar
|
// NavBar
|
||||||
@nav-bar-height: 44px;
|
@nav-bar-height: 46px;
|
||||||
@nav-bar-background-color: @white;
|
@nav-bar-background-color: @white;
|
||||||
@nav-bar-text-color: @blue;
|
|
||||||
@nav-bar-arrow-size: 16px;
|
@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-font-size: @font-size-lg;
|
||||||
@nav-bar-title-text-color: @text-color;
|
@nav-bar-title-text-color: @text-color;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
&__content {
|
&__content {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__text {
|
&__text {
|
||||||
@ -27,8 +28,8 @@
|
|||||||
|
|
||||||
&__arrow {
|
&__arrow {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
.theme(font-size, '@nav-bar-arrow-size');
|
.theme(font-size, '@nav-bar-arrow-size') !important;
|
||||||
.theme(color, '@nav-bar-text-color');
|
.theme(color, '@nav-bar-icon-color') !important;
|
||||||
|
|
||||||
+ .van-nav-bar__text {
|
+ .van-nav-bar__text {
|
||||||
margin-left: -20px;
|
margin-left: -20px;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { VantComponent } from '../common/component';
|
import { VantComponent } from '../common/component';
|
||||||
import { getSystemInfoSync } from '../common/utils';
|
import { getRect, getSystemInfoSync } from '../common/utils';
|
||||||
|
|
||||||
VantComponent({
|
VantComponent({
|
||||||
classes: ['title-class'],
|
classes: ['title-class'],
|
||||||
@ -33,20 +33,15 @@ VantComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
data: {
|
data: {
|
||||||
statusBarHeight: 0,
|
height: 46,
|
||||||
height: 44,
|
|
||||||
baseStyle: '',
|
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
const { statusBarHeight } = getSystemInfoSync();
|
const { statusBarHeight } = 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: 46 + statusBarHeight,
|
||||||
baseStyle,
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -69,11 +64,9 @@ VantComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx.nextTick(() => {
|
wx.nextTick(() => {
|
||||||
this.getRect('.van-nav-bar').then(
|
getRect.call(this, '.van-nav-bar').then((res) => {
|
||||||
(res: WechatMiniprogram.BoundingClientRectCallbackResult) => {
|
|
||||||
this.setData({ height: res.height });
|
this.setData({ height: res.height });
|
||||||
}
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||||
|
<wxs src="./index.wxs" module="computed" />
|
||||||
|
|
||||||
<view wx:if="{{ fixed && placeholder }}" style="height: {{ height }}px;" />
|
<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="{{ baseStyle }}; {{ customStyle }}"
|
style="{{ computed.barStyle({ zIndex, statusBarHeight, safeAreaInsetTop }) }}; {{ customStyle }}"
|
||||||
>
|
>
|
||||||
<view class="van-nav-bar__content">
|
<view class="van-nav-bar__content">
|
||||||
<view class="van-nav-bar__left" bind:tap="onClickLeft">
|
<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