uniapp制作app与小程序前端——侧边导航栏

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


一.实现的代码与配置

1.找到相应配置文件
在这里插入图片描述

2.打入代码(如下)

<template>
	<view class='center'>
		<view class='center-list'>
		<view class="pics">
			<scroll-view class="gundong" scroll-y v-for="(item,index) in navLeft" :key="index">
				<view :class="{'active':isActive === index}" @click="checked(index)">
				  {{item.tit}}
				</view>
			</scroll-view>
		</view>
		</view>
	</view>
</template>
 
<script>
	export default {
		data (){
			return {
				isActive:0,
				navLeft:[
					{index:0,tit:"事例1"},
					{index:1,tit:"事例2"},
					{index:2,tit:"事例3"},
					{index:3,tit:"事例4"},
					{index:4,tit:"事例5"},
					{index:5,tit:"事例6"},
					{index:6,tit:"事例7"},
					{index:7,tit:"事例8"},
					{index:8,tit:"事例9"},
					{index:9,tit:"事例10"},
					{index:10,tit:"事例11"},
					{index:11,tit:"事例12"},
					{index:12,tit:"事例13"}
				]
			}
		},
		methods:{
			checked(index) {
				this.isActive = index
			}
		}
	}
</script>
 
<style>
	page {
		height:100%;
	}
	.center{
		width:100%;
		height:100%;
		position:relative;
	}
	.center-list{
		width: 200rpx;
		height:86%;
		position: fixed;
		overflow: auto;
	}
	.pics {
		width:100%;
		height:auto;
	}
	.gundong {
	  width: 200rpx;
	  height: 100rpx;
	}
	.gundong view {
	  height: 100rpx;
	  line-height: 100rpx;
	  text-align: center;
	/*  background-color: #f1f1f1; */
	  font-size:28rpx;
	  color:#666;
	}
	.active {
		color:#333;
		font-weight:700;
		border-left:8rpx solid #ff5934;
	}
</style>

二. 效果展示

在这里插入图片描述

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值