当前位置:网站首页>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>
边栏推荐
- Dynamic sorting of DOM object element blocks in applets
- Day 2
- 微信小程序-组件传参,状态管理
- uniapp组件之倒计时(如阅读协议倒计时、完成学习倒计时)
- Wechat applet - screen height
- ClickHouse学习(六)语法优化
- 弹性盒子相关知识
- [C language series] - storage of deep anatomical data in memory (II) - floating point type
- 移动端-flex项目属性
- [C language series] - constants and variables that confuse students
猜你喜欢
随机推荐
Terminal shell common commands
Question swiping Madness - leetcode's sword finger offer58 - ii Detailed explanation of left rotation string
PyQt5:第一章第1节:使用Qt组件创建一个用户界面-介绍
Summary of knowledge points related to forms and forms
Flask 报错 RuntimeError: The session is unavailable because no secret key was set.
Hcia-r & s self use notes (27) comprehensive experiment
用threejs 技术做游戏跑酷
利用Poi-tl在word模板表格单元格内一次插入多张图片和多行单元格相同数据自动合并的功能组件
重绘与回流的关系
Day 1
虚拟增强与现实第二篇 (我是一只火鸟)
[C language series] - a recursive topic
第三课threejs全景预览房间案例
Introduction to C language array to proficiency (array elaboration)
Global components component registration
link与@import导入外部样式的区别
AR虚拟增强与现实
Three handshakes and four waves for the interview summary
Li Kou 994: rotten orange (BFS)
uniapp之常用提示弹框