TopBar.vue 1002 Bytes
Newer Older
王建威's avatar
王建威 committed
1
<template>
王建威's avatar
王建威 committed
2
	<view class="topbar_view" :style="[{'color': titleColor, 'background-color': bgColor}, bold ? {'font-weight':900} : 'initial']">
王建威's avatar
王建威 committed
3
		<text class="eosfont left_icon" @click="back()">&#xe622;</text>
王建威's avatar
王建威 committed
4 5 6 7 8 9 10 11 12 13
		{{this.title}}
	</view>
</template>

<script>
	export default {
		props: {
			title: {
				type: String,
				default: ''
王建威's avatar
王建威 committed
14 15 16 17 18 19 20 21
			},
			titleColor: {
				type: String,
				default: '#212121'
			},
			bgColor: {
				type: String,
				default: '#fff'
王建威's avatar
王建威 committed
22 23 24 25
			},
			bold: {
				type: Boolean,
				default: false
王建威's avatar
王建威 committed
26 27 28 29
			}
		},
		methods: {
			back() {
30 31 32 33 34 35
				const routes = getCurrentPages();
				if(routes.length > 1){
					uni.navigateBack();
				}else{
					history.back();
				}
王建威's avatar
王建威 committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
			}
		}
	}
</script>

<style lang="less" scoped>
	.topbar_view {
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		color: #212121;
		font-size: 30rpx;
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		background-color: #fff;
王建威's avatar
王建威 committed
53
		z-index: 100;
王建威's avatar
王建威 committed
54 55 56 57 58 59
		.left_icon {
			position: absolute;
			left: 20rpx;
		}
	}
</style>