diff --git a/example/pages/nav-bar/index.wxml b/example/pages/nav-bar/index.wxml
index e25fb13a..b61ba556 100644
--- a/example/pages/nav-bar/index.wxml
+++ b/example/pages/nav-bar/index.wxml
@@ -1,7 +1,6 @@
-
+
diff --git a/example/project.config.json b/example/project.config.json
index 885a07ff..5f82a265 100644
--- a/example/project.config.json
+++ b/example/project.config.json
@@ -23,7 +23,7 @@
"disablePlugins": [],
"outputPath": ""
},
- "useCompilerModule": false,
+ "useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false
},
"compileType": "miniprogram",
diff --git a/packages/nav-bar/index.less b/packages/nav-bar/index.less
index 256bd8d1..e11d4b72 100644
--- a/packages/nav-bar/index.less
+++ b/packages/nav-bar/index.less
@@ -9,6 +9,10 @@
.theme(line-height, '@nav-bar-height');
.theme(background-color, '@nav-bar-background-color');
+ &__content {
+ position: relative;
+ }
+
&__text {
display: inline-block;
vertical-align: middle;
@@ -50,6 +54,7 @@
&__left,
&__right {
position: absolute;
+ top: 0;
bottom: 0;
display: flex;
align-items: center;
diff --git a/packages/nav-bar/index.ts b/packages/nav-bar/index.ts
index 3386e2f2..88c51b5b 100644
--- a/packages/nav-bar/index.ts
+++ b/packages/nav-bar/index.ts
@@ -1,4 +1,5 @@
import { VantComponent } from '../common/component';
+import { getSystemInfoSync } from '../common/utils';
VantComponent({
classes: ['title-class'],
@@ -38,14 +39,14 @@ VantComponent({
},
created() {
- const { statusBarHeight } = wx.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({
statusBarHeight,
height: 44 + statusBarHeight,
- baseStyle
+ baseStyle,
});
},
diff --git a/packages/nav-bar/index.wxml b/packages/nav-bar/index.wxml
index 941bf563..27ba8c96 100644
--- a/packages/nav-bar/index.wxml
+++ b/packages/nav-bar/index.wxml
@@ -4,36 +4,38 @@
-
-
-
+
+
+
+
+ {{ leftText }}
+
+
+
+
+ {{ title }}
+
+
+
{{ leftText }}
-
-
-
-
- {{ title }}
-
-
-
- {{ rightText }}
-
+ >{{ rightText }}
+
+