Browse Source

导航条返回上一页

Xiao_123 1 month ago
parent
commit
47437c8b8e
1 changed files with 27 additions and 11 deletions
  1. 27 11
      components/Navbar/index.vue

+ 27 - 11
components/Navbar/index.vue

@@ -14,7 +14,10 @@
         class="navbar-box-logo" 
         :style="{'height': defaultLogoHeight + 'px'}"
       ></image>
-      <view v-else class="navbar-box-title" :class="[{'text-left': textLeft}, {'text-center': !textLeft}]">{{ title }}</view>
+      <view v-else class="nav-box-title">
+        <uni-icons type="left" size="25" class="ss-m-l-20" color="#0E100F" @tap="goBack"></uni-icons>
+        <view class="title-text" :class="[{'text-left': textLeft}, {'text-center': !textLeft}]">{{ title }}</view>
+      </view>
     </view>
   </view>
 </template>
@@ -69,6 +72,12 @@ onLoad(() => {
     console.error('获取系统信息或菜单按钮信息时出错:', error)
   }
 })
+
+const goBack = () => {
+  uni.navigateBack({
+    delta: 1
+  });
+}
 </script>
 
 <style scoped lang="scss">
@@ -90,15 +99,22 @@ onLoad(() => {
       left: 10px;
       width: 95px;
     }
-    &-title {
-      position: absolute;
-      width: 158px;
-      height: 51px;
-      line-height: 51px;
-      color: #0E100F;
-      font-style: normal;
-      text-transform: none;
-    }
+  }
+}
+.nav-box-title {
+  position: relative;
+  width: 100%;
+  height: 100%;
+  display: flex;
+  align-items: center;
+  .title-text {
+    position: absolute;
+    width: 158px;
+    height: 51px;
+    line-height: 51px;
+    color: #0E100F;
+    font-style: normal;
+    text-transform: none;
   }
 }
 .text-left {
@@ -111,6 +127,6 @@ onLoad(() => {
 	left: 50%;
 	transform: translateX(-50%);
 	font-family: MiSans-Medium;
-	font-size: 38rpx;
+	font-size: 33rpx;
 }
 </style>