效果图
代码
<view class="distance-select-list">
<view v-for="(item,index) in distanceList" :key="index">
<view class="distance-select-list-item" :class="{'distance-select-list-item-active': distanceTypeSelect === index}" @tap="tapDistanceType(index)">
{{item}}km
</view>
</view>
</view>
// 点击距离类型item的触发事件
tapDistanceType(index){
this.distanceTypeSelect = index
},
distanceList: [1,2,3,5,10,20,30,50,100,200],
distanceTypeSelect:0
.distance-select-list{
display: flex;
flex-wrap: wrap;
padding: 16rpx;
background-color: white;
}
.distance-select-list-item{
width: 136rpx;
margin: 8rpx;
padding: 6rpx 0;
text-align: center;
border: 2rpx solid #ddd;
border-radius: 999rpx;
}
.distance-select-list-item-active{
color: #23CFF7;
background-color: rgb(229,248,242);
border: 2rpx solid #23CFF7;
}
|