uni-app顶部导航栏 下拉滑动固定到屏幕顶部

示例图片
在这里插入图片描述

代码

<template>
	<view style="display: flex;flex: row; position:fixed; left: 0; width: 100%; top: 30;z-index: 999;">
		<scroll-view scroll-x class="bg-white nav" scroll-with-animation :scroll-left="scrollLeft">
			<view class="cu-item" :class="index==TabCur?'text-green cur':''" v-for="(item,index) in statusList" :key="index" @tap="tabSelect" :data-id="index">
				{{item}}
			</view>
		</scroll-view>
	</view>
</template>
<script>
	export default {
		components: {
		},
		data() {
			return {
				TabCur: 0,
				scrollLeft: 0
			}
		},
		methods: {
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
				console.log(this.TarCur)
			},
		}
	}
</script>
<style>

/* ==================
         导航栏
 ==================== */

.nav {
	white-space: nowrap;
}

::-webkit-scrollbar {
	display: none;
}

.nav .cu-item {
	height: 90upx;
	display: inline-block;
	line-height: 90upx;
	margin: 0 10upx;
	padding: 0 20upx;
}

.nav .cu-item.cur {
	border-bottom: 4upx solid;
}
.text-green,
.line-green,
.lines-green {
	color: #39b54a;
}
.bg-white {
	background-color: #ffffff;
	color: #666666;
}
.nav .cu-item.cur {
	border-bottom: 4upx solid;
}
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值