| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <template>
- <view class="nav-bar" :style="{ backgroundColor: bgColor }">
- <view class="status-bar" :style="{ height: statusBarHeight + 'px' }"></view>
- <view class="nav-content">
- <view class="left-box" @click="goBack" v-if="showBack">
- <uni-icons type="left" size="20" :color="color"></uni-icons>
- </view>
- <view class="title-box">
- <text class="title-text" :style="{ color: color }">{{ title }}</text>
- </view>
- <view class="right-box">
- <slot name="right"></slot>
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import { ref, onMounted } from 'vue'
- const props = defineProps({
- title: {
- type: String,
- default: ''
- },
- showBack: {
- type: Boolean,
- default: true
- },
- bgColor: {
- type: String,
- default: '#ffffff'
- },
- color: {
- type: String,
- default: '#000000'
- }
- })
- const statusBarHeight = ref(44)
- onMounted(() => {
- const sysInfo = uni.getSystemInfoSync()
- statusBarHeight.value = sysInfo.statusBarHeight || 44
- })
- const goBack = () => {
- uni.navigateBack()
- }
- </script>
- <style lang="scss" scoped>
- .nav-bar {
- position: sticky;
- top: 0;
- z-index: 999;
- width: 100%;
- }
- .nav-content {
- height: 44px;
- display: flex;
- align-items: center;
- padding: 0 32rpx;
- position: relative;
- }
- .left-box {
- position: absolute;
- left: 32rpx;
- z-index: 10;
- }
- .title-box {
- flex: 1;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .title-text {
- font-size: 32rpx;
- font-weight: bold;
- }
- .right-box {
- position: absolute;
- right: 32rpx;
- }
- </style>
|