uniapp自定义头部导航

uniapp自定义头部导航

javascript 复制代码
<template>
	<view>
		<view class="dynamic" :style="{'border-bottom':borderBottom}">
			<view :style="{'width':'100%','height':statusBarHeight+'px','background-color':backgourndColor}"></view>
			<view class="dynamicBox" :style="{'background-color':backgourndColor,'height':'80rpx','width':'100%'}">
				<view :style="{'width': bothSidesWidth,'height': '100%','display': 'flex','align-items': 'center'}" v-if="pattern!='normal'">
					<image src="/static/image/whiteBack.png" @tap="goback" style="width: 44rpx;height: 44rpx;"></image>
				</view>
				<image src="/static/image/whiteBack.png" v-if="pattern=='normal'" @tap="goback" style="width: 44rpx;height: 44rpx;"></image>
				<view class="navtitle" :style="{'color':fontColor,'font-size':fontSize,'font-weight':fontWeight}">{{title}}</view>
				<view :style="{'width': bothSidesWidth,'height':'100%'}" v-if="pattern!='normal'">
					<slot></slot>
				</view>
				<view style="width: 44rpx;height:100%;" v-if="pattern=='normal'"></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				statusBarHeight:getApp().globalData.mySystemInfo.statusBarHeight,//状态栏高度
			}
		},
		props:{
			//名称
			title:{
				type:String,
				default:'详情'
			},
			//右侧是否显示
			pattern:{
				type:String,
				default:'normal'
			},
			//背景颜色
			backgourndColor:{
				type:String,
				default:'#ffc526'
			},
			//文字颜色
			fontColor:{
				type:String,
				default:'#fff'
			},
			//两侧宽度
			bothSidesWidth:{
				type:String,
				default:'130rpx'
			},
			//下边框
			borderBottom:{
				type:String,
				default:'none'
			},
			//返回按钮形式
			backType:{
				type:String,
				default:'normal'
			},
			//文字大小
			fontSize:{
				type:String,
				default:'34rpx'
			},
			//文字加粗
			fontWeight:{
				type:Number,
				default:600
			}
		},
		methods:{
			//返回
			goback(e){
				if(this.backType == 'normal'){
					uni.navigateBack()
				}else{
					this.$emit('backOperation')
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.dynamic{
		width: 100%;		
		.dynamicBox{
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 20rpx;
			box-sizing: border-box;
			font-size: 0;
			.navtitle{
				max-width: 500rpx;
				white-space: nowrap;
				overflow: hidden;
			}
		}
	}
</style>
相关推荐
XiaoYu20022 分钟前
第8章 Three.js入门
前端·javascript·three.js
这个一个非常哈13 分钟前
element之,自定义form的label
前端·javascript·vue.js
阿东在coding28 分钟前
Flutter 测试框架对比指南
前端
是李嘉图呀32 分钟前
npm推送包失败需要Two-factor权限认证问题解决
前端
自己记录_理解更深刻32 分钟前
本地完成「新建 GitHub 仓库 react-ts-demo → 关联本地 React+TS 项目 → 提交初始代码」的完整操作流程
前端
借个火er34 分钟前
Chrome 插件开发实战:5 分钟上手 + 原理深度解析
前端
攀登的牵牛花34 分钟前
前端向架构突围系列 - 架构方法(一):概述 4+1 视图模型
前端·设计模式·架构
Hashan35 分钟前
Vue 3 中 v-for 动态组件 ref 收集失败问题排查与解决
前端·vue.js·前端框架
bobringtheboys36 分钟前
[el-tag]使用多个el-tag,自动判断内容是否超出
前端·javascript·vue.js
ccccc__37 分钟前
基于vue3完成领域模型架构建设
前端