css class 多种规则判断样式

需求

商品分类选择变量 上下的分类需要添加圆角 这个就设计到多个分类的判断

解决方法

在class里面多写些判断 判断上下的分类 做成圆角即可

代码

html 复制代码
<!-- html -->				
<view v-for="(item,index) in tabbar" :key="index" class="u-tab-item" :class="`${current == index ? 'u-tab-item-active' : ''}
	${current > 0 && current - 1 == index ? 'radius-bottom' : ''} 
	${current < tabbar.length - 1 && current + 1 == index ? 'radius-top' : ''}`" 
				 @tap.stop="swichMenu(index)">
					<text class="u-line-1">{{item.name}}</text>
				</view>

// css
	.u-tab-item-active {
		position: relative;
		color: #000;
		font-size: 30rpx;
		font-weight: 600;
		background: #fff;
	}

	.u-tab-item-active::before {
		content: "";
		position: absolute;
		border-left: 6px solid $u-primary;
		border-radius: 15rpx;
		height: 32rpx;
		left: 0;
		top: 39rpx;
	}
	.radius-top {
		border-top-right-radius: 30rpx;
	}
	.radius-bottom {
		border-bottom-right-radius: 30rpx;
	}
相关推荐
Enti7c26 分钟前
用 HTML、CSS 和 JavaScript 实现抽奖转盘效果
前端·css
LCG元30 分钟前
Vue.js组件开发-使用Vue3如何实现上传word作为打印模版
前端·vue.js·word
dal118网工任子仪1 小时前
94,【2】buuctf web [安洵杯 2019]easy_serialize_php
android·前端·php
大模型铲屎官1 小时前
HTML5 技术深度解读:本地存储与地理定位的最佳实践
前端·html·html5·本地存储·localstorage·地理定位·geolocation api
一 乐2 小时前
基于vue船运物流管理系统设计与实现(源码+数据库+文档)
前端·javascript·数据库·vue.js·spring boot·后端·船运系统
m0_528723812 小时前
在React中使用redux
前端·javascript·react.js
傻小胖3 小时前
vue3中customRef的用法以及使用场景
前端·javascript·vue.js
谦谦橘子3 小时前
手把手教你实现一个富文本
前端·javascript
Future_yzx3 小时前
Java Web的发展史与SpringMVC入门学习(SpringMVC框架入门案例)
java·前端·学习
用户6823806032253 小时前
一次全栈项目部署 centos+pm2+nginx+mysql
前端