<template>
	<view>
		<view class="navbar" :class="{'fix': isfix,'bgclass': isbgf}">
			<view class="item" 
			:class="{'select': cureentNavbarIndex == index}"
			v-for="(item,index) in navbarList" 
			:key="index" 
			@click="handleItemClick(index)"
			>
				{{item}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cureentNavbarIndex: 0,
			}
		},
		mounted() {
			console.log(this.topHeight,'高度')
		},
		props: {
			navbarList: {
				type: Array,
				default() {
					return []
				}
			},
			isfix: {
				type: Boolean,
				default: false
			},
			topHeight: {
				type: Number,
				default: 0
			},
			leftWidth: {
				type: Number,
				default: 30
			},
			isbgf: {
				type: Boolean,
				default: false
			}
		},
		methods: {
			handleItemClick(index) {
				this.cureentNavbarIndex = index
				this.$emit('navbarChange',index)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.navbar {
		width: 690rpx;
		height: 50rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: auto;
		.item {
			width: auto;
			height: 50rpx;
			border-radius: 25rpx;
			line-height: 50rpx;
			text-align: center;
			font-size: 28rpx;
			color: #999;
			padding: 0 32rpx;
		}
		.select {
			color: #fff;
			background: linear-gradient(270deg, #FDAD26 0%, #FF8F86 100%);
		}
	}
	
	.fix {
		position: fixed;
		background-color: #F8F8F8;
		z-index: 9999;
		padding: 30upx;
	}
	
	.bgclass {
		padding: 30upx;
		background-color: #fff;
		z-index: 9999;
	}
</style>
