当前位置:   article > 正文

uniapp自定义头部导航

uniapp自定义头部导航

uniapp自定义头部导航

<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>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/422302
推荐阅读
相关标签
  

闽ICP备14008679号