Jelajahi Sumber

fix:返回按钮显示

jianghaili 7 bulan lalu
induk
melakukan
546109380b
1 mengubah file dengan 65 tambahan dan 62 penghapusan
  1. 65 62
      components/nav-bar/index.vue

+ 65 - 62
components/nav-bar/index.vue

@@ -3,7 +3,7 @@
 		<view class="go-back">
 		<view class="go-back">
 			<u-icon name="arrow-leftward" :color="color" size="32" @click="goBack" v-if="isBack"></u-icon>
 			<u-icon name="arrow-leftward" :color="color" size="32" @click="goBack" v-if="isBack"></u-icon>
 		</view>
 		</view>
-		<view class="nav-title" :style="{color:color}">
+		<view class="nav-title" :style="{ color: color }">
 			{{ title }}
 			{{ title }}
 		</view>
 		</view>
 		<view class="go-back">
 		<view class="go-back">
@@ -12,76 +12,79 @@
 	</view>
 	</view>
 </template>
 </template>
 <script>
 <script>
-	export default {
-		props: {
-			title: "",
-			color: '',
-			backUrl: {
-			    type: String,
-			    default: ''
-			},
-			isBack:true,
+export default {
+	props: {
+		title: "",
+		color: '',
+		backUrl: {
+			type: String,
+			default: ''
 		},
 		},
-		data() {
-			return {
-				BarHeight: '',
-			};
+		isBack: {
+			type: Boolean,
+			default: true  // 这里默认是 true
 		},
 		},
-		mounted() {
-			// #ifdef APP-PLUS
-			let systemInfo = uni.getSystemInfoSync();
-			this.BarHeight = systemInfo.statusBarHeight;
-			// #endif
-		},
-		methods:{
-			goBack() {
-				if (this.backUrl) {
-					const isTabPage = [
-						'/pages/index/index',
-						'/pages/index/game/gameList',
-						'/pages/msg/index',
-						'/pages/my/index'
-					].includes(this.backUrl)
-					if (isTabPage) {
-						uni.switchTab({
-							url: this.backUrl
-						})
-					} else {
-						uni.redirectTo({
-							url: this.backUrl
-						})
-					}
+	},
+	data() {
+		return {
+			BarHeight: '',
+		};
+	},
+	mounted() {
+		// #ifdef APP-PLUS
+		let systemInfo = uni.getSystemInfoSync();
+		this.BarHeight = systemInfo.statusBarHeight;
+		// #endif
+	},
+	methods: {
+		goBack() {
+			if (this.backUrl) {
+				const isTabPage = [
+					'/pages/index/index',
+					'/pages/index/game/gameList',
+					'/pages/msg/index',
+					'/pages/my/index'
+				].includes(this.backUrl)
+				if (isTabPage) {
+					uni.switchTab({
+						url: this.backUrl
+					})
 				} else {
 				} else {
-					uni.navigateBack()
+					uni.redirectTo({
+						url: this.backUrl
+					})
 				}
 				}
+			} else {
+				uni.navigateBack()
 			}
 			}
 		}
 		}
-	};
+	}
+};
 </script>
 </script>
 <style lang="scss" scoped>
 <style lang="scss" scoped>
-	.nav-bar {
-		width: 100%;
-		padding: 24rpx 32rpx 20rpx 32rpx;
-		box-sizing: border-box;
-		color: rgba(255, 255, 255, 1);
-		font-family: DM Sans;
-		font-size: 30rpx;
-		font-weight: 700;
-		line-height: 26px;
-		display: flex;
-		// justify-content: center;
-		align-items: center;
-		position: relative;
-		z-index: 9999;
+.nav-bar {
+	width: 100%;
+	padding: 24rpx 32rpx 20rpx 32rpx;
+	box-sizing: border-box;
+	color: rgba(255, 255, 255, 1);
+	font-family: DM Sans;
+	font-size: 30rpx;
+	font-weight: 700;
+	line-height: 26px;
+	display: flex;
+	// justify-content: center;
+	align-items: center;
+	position: relative;
+	z-index: 9999;
 
 
-		.go-back {
-			width: 32.61px;
-			height: 26px;
-		}
+	.go-back {
+		width: 32.61px;
+		height: 26px;
+	}
 
 
-		.nav-title {
-			flex: 1;
-			text-align: center;
-		}
+	.nav-title {
+		flex: 1;
+		text-align: center;
 	}
 	}
+}
 </style>
 </style>