当前位置:网站首页>Selection options of uniapp components (such as package selection)
Selection options of uniapp components (such as package selection)
2022-07-29 05:41:00 【Weisen】
Functional effect :

The code is as follows :
<template>
<view class="text-data">
<view class="text-item" v-for="(item, index) in list" :key='index' @click="clicktab(index)" :class="{active:activeindex===index}">
<view>
<!-- Click to change the picture -->
<image :src="activeindex===index? '../../static/img/2.png' : '../../static/img/1.png'"></image>
</view>
<view>
{
{item.name}}
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
list:[
{name:' package 1'},
{name:' package 2'},
{name:' package 3'},
],
// No one is selected by default , by 0, The first... Is selected by default
activeindex: -1,
}
},
methods: {
clicktab(index){
// You can select and cancel ( here index Index the selected subitems )
this.activeindex = this.activeindex==index?-1:index;
// this.activeindex = index; Cannot cancel after selection
}
}
}
</script>
<style lang="scss">
.text-data{
display: flex;
flex-direction: row;
height: 80px;
margin-top: 20px;
justify-content: space-between;
.text-item{
margin-left: 20rpx;
margin-right: 20rpx;
height: 80px;
width: 120px;
border: 1px #d4d4d4 solid;
display: flex;
image{
height: 20px;
width: 20px;
}
// The style changes after clicking
&.active{
color: #ff0000;
background-color: #faf8f4;
border:1px #808270 solid;
}
}
}
</style>边栏推荐
- 【TypeScript】深入学习TypeScript函数
- Selenium实战案例之爬取js加密数据
- Fvuln-自动化web漏洞检测工具
- Question swiping Madness - leetcode's sword finger offer58 - ii Detailed explanation of left rotation string
- [typescript] learn typescript object types in depth
- 【电子电路】ADC芯片如何选型
- Niuke network programming problem - [wy22 Fibonacci series] and [replace spaces] detailed explanation
- [C language series] - a recursive topic
- HCIA-R&S自用笔记(26)PPP
- 微信小程序-组件传参,状态管理
猜你喜欢
随机推荐
Terminal shell common commands
Day 3
[C language series] - constants and variables that confuse students
第三课threejs全景预览房间案例
ClickHouse学习(九)clickhouse整合mysql
Storage category
Detailed explanation of serial port communication
Detailed explanation of typical application code of C language array - master enters by mistake (step-by-step code explanation)
Wechat applet - screen height
Fvuln-自动化web漏洞检测工具
[sword finger offer] - explain the library function ATOI and simulate the realization of ATOI function
利用Poi-tl在word模板表格单元格内一次插入多张图片和多行单元格相同数据自动合并的功能组件
table中同一列中合并相同项
Talking about Servlet
ClickHouse学习(十)监控运行指标
Li Kou 994: rotten orange (BFS)
About local variables
使用微信小程序扫码登录系统PC端web的功能
弹性盒子flex
Thrift安装手册

![[sword finger offer] - explain the library function ATOI and simulate the realization of ATOI function](/img/13/a506861da2db8f5a5181e6d82894b3.png)







