【uni点击导航切换内容,简单版(仅适用于内容固定而且很少的情况下使用)】

uni-app实现仿美团菜单,点击导航切换内容(NO.2)

仅适用于内容固定而且很少的情况下使用,导航因为内容少,样式是自己写的,不是滚动型,文字底部高亮是伪类,跟随文字位置

点击左边菜单,右边滚动相应内容

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

1.template,这里只放切换的代码

	<view>
	<view class="plan1 fle bor_bot">
		<view class="item fle_all " v-for="(item,index) in menu_name" :class="index==lun3?'cur':''" @tap="lun_bo(index)">
			<view class="text ">
				<text class="fle_all"> {{item.name}}</text>
			</view>
			<view class="text2">
				<text>01</text>
			</view>
		</view>
	</view>
		<view class="plan2" v-if="lun3==0">
				点餐
			</view>
			<view class="plan3 fle" v-if="lun3==1">
				评价
			</view>
</view>

2.css

		.plan3 {
		height: 100rpx;
	}

	.plan3 .item {
		padding: 0rpx 40rpx;
	}

	.plan3 .text {
		display: block;
		height: 100%;
		position: relative;
	}

	.plan3 .cur {
		color: #007AFF;
		position: relative;
	}

	.plan3 .cur::after {
		content: '';
		position: absolute;
		left: 58rpx;
		top: auto;
		bottom: -2rpx;
		right: auto;
		height: 6rpx;
		width: 40rpx;
		background-color: #32b66b;
	}

	.plan3 .text text {
		font-size: 36rpx;
		font-weight: bold;
		height: 100%;
	}

	.plan3 .text2 {
		width: 10rpx;
		position: relative;
	}

	.plan3 .text2 text {
		position: absolute;
		top: -6rpx;
		margin-left: 8rpx;
		font-size: 22rpx;
		font-weight: bold;
		color: #bbb;
	}

3.script

		<script>
	export default {
		data() {
			return {
				menu_name: [{
					name: '点菜'
				}, {
					name: '评价'
				}, {
					name: '商家'
				}],
				lun3: 0,
			}
		},
		methods: {
			lun_bo(e) {
				this.lun3 = e
			},
		}
	}
</script>
看完点个赞吧
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值