CustomNav.nvue 1.21 KB
<template>
	<view class="header" :style="`background-color:${bgColor}`">
		<StatusBar />
		<uv-navbar
			class="custom-nav-bar"
			:title="title"
			:bg-color="bgColor"
			:titleStyle="{fontSize:'32rpx',fontWeight:'bold',color: titleColor}"
		>
    <template v-slot:left>
       <slot name="left"></slot>
       <template v-if="!$slots.left">
         <view v-if="isTab"></view>
         <uv-icon v-else name="arrow-left" :color="arrowLeftColor" size="20px" @tap="backTo" />
       </template>
    </template>
    <template v-slot:right>
      <slot name="right"></slot>
    </template>
    </uv-navbar>
		<view v-if="commonNav" style="height: 44px;"></view>
	</view>
</template>

<script setup>
	import StatusBar from '@/components/StatusBar.vue';

	defineProps({
		title: {
			type: String,
			required: true
		},
		bgColor:{
			type: String,
			// default: '#3277FB'
			default: '#3277FB'
		},
    isTab:{
      type: Boolean,
			default: false
		},
	titleColor:{
		type: String,
		default: '#ffffff'
	},
	arrowLeftColor:{
		type: String,
		default: '#ffffff'
	},
	commonNav:{
		type: Boolean,
		default: true
	}
	})
  const backTo = ()=>{
    uni.navigateBack({
      delta: 1
    })
  }

</script>

<style lang="scss" scoped>

</style>