first commit
This commit is contained in:
111
src/components/customHeader.vue
Normal file
111
src/components/customHeader.vue
Normal file
@@ -0,0 +1,111 @@
|
||||
<template>
|
||||
<view class="custom-navbar">
|
||||
<view class="navbar-main" :style="{paddingTop:navBarPaddingTop+'px'}">
|
||||
<!-- 左侧内容 -->
|
||||
<view class="navbar-left" @click="handleBack" v-if="leftFlag">
|
||||
<uni-icons type="left" size="24" color="#fff"></uni-icons>
|
||||
</view>
|
||||
|
||||
<!-- 中间标题 -->
|
||||
<view class="navbar-title">{{ title }}</view>
|
||||
|
||||
<!-- 右侧内容 -->
|
||||
<view class="navbar-right" v-if="rightFlag">
|
||||
<slot name="right"></slot>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getNavBarPaddingTop,getNavBarHeight,getStatusBarHeight} from '@/utils/system.js'
|
||||
|
||||
const props = defineProps({
|
||||
title: String,
|
||||
leftFlag:true,//默认左侧显示 false-不显示
|
||||
rightFlag:false,//默认右侧不显示
|
||||
})
|
||||
|
||||
const emit = defineEmits(['back'])
|
||||
|
||||
let navBarPaddingTop = ref(0)
|
||||
let statusBarHeight = ref(0)
|
||||
let navbarHeight = ref(0)
|
||||
let navHeight = ref(0)
|
||||
|
||||
onMounted(() => {
|
||||
navBarPaddingTop.value = getNavBarPaddingTop();console.log(navBarPaddingTop.value)
|
||||
statusBarHeight.value = getStatusBarHeight();
|
||||
navbarHeight.value = getNavBarHeight();
|
||||
navHeight.value = navbarHeight.value - statusBarHeight.value
|
||||
})
|
||||
|
||||
const handleBack = () => {
|
||||
emit('back')
|
||||
uni.navigateBack()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.custom-navbar {
|
||||
width: 750rpx;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
margin-left:-375rpx;
|
||||
z-index: 999;
|
||||
/* #ifdef APP-PLUS */
|
||||
background: url('@/static/images/bg-Blue-header.png') no-repeat;
|
||||
background-size:750rpx 160rpx;
|
||||
height:160rpx;
|
||||
/* #endif */
|
||||
|
||||
/* #ifndef APP-PLUS */
|
||||
background: url('@/static/images/bg-Blue-header2.png') no-repeat;
|
||||
background-size:750rpx 116rpx;
|
||||
height:116rpx;
|
||||
/* #endif */
|
||||
|
||||
}
|
||||
|
||||
.navbar-content {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.navbar-main {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 30rpx;
|
||||
box-sizing: border-box;
|
||||
color:#fff;
|
||||
/* #ifdef APP-PLUS */
|
||||
height:160rpx;
|
||||
/* #endif */
|
||||
/* #ifndef APP-PLUS */
|
||||
height:116rpx;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.navbar-left{
|
||||
width: 70rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.navbar-title {
|
||||
flex: 1;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color:#fff;
|
||||
margin-top:-3rpx;
|
||||
}
|
||||
|
||||
.navbar-right{
|
||||
margin-left: auto;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user