uniapp实现左侧滚动条item选中样式

要实现如下效果

代码如下

<template>
	<view class="main">
		<scroll-view scroll-y class="left_sv">
			<view class="menu_item" v-for="(item, index) in list" :key="item.id" :class="active_index === item.id ? 'active' : ''" @click="handle_tab(index)">{{ item.name }}</view>
		</scroll-view>
		<scroll-view scroll-y class="right_sv">
			<view>2233333333333333333333</view>
			<view>2222222222222222</view>
		</scroll-view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			active_index: 0,
			list: [
				{
					id: 0,
					name: 'hello'
				},
				{
					id: 1,
					name: 'hello1'
				},
				{
					id: 2,
					name: 'hello2'
				},
				{
					id: 3,
					name: 'hello3'
				}
			]
		};
	},

	methods: {
		handle_tab(index) {
			this.active_index = index;
		}
	}
};
</script>

<style lang="scss">
.main {
	display: flex;
	height: 100vh;
	.left_sv {
		flex: 2;
		.menu_item {
			padding: 20rpx 0;
			text-align: center;
			font-size: 40rpx;
			background-color: #dd524d;
			margin-bottom: 10rpx;
		}
		.active {
			font-size: 50rpx;
			color: #f0ad4e;
		}
	}
	.right_sv {
		flex: 5;
		background-color: #4cd964;
	}
}
</style>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值