当前位置:网站首页>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>边栏推荐
- Basic concepts of MySQL + database system structure + extended application + basic command learning
- Thrift安装手册
- 弹性盒子flex
- Clickhouse learning (VII) table query optimization
- C language n queen problem
- [typescript] type reduction (including type protection) and type predicate in typescript
- ClickHouse学习(六)语法优化
- uniapp组件之倒计时(如阅读协议倒计时、完成学习倒计时)
- shell基本操作(上)
- Storage category
猜你喜欢

Longest string without duplicate characters

uniapp之常用提示弹框

全局components组件注册

【TypeScript】深入学习TypeScript函数

Wechat applet - component parameter transmission, state management

Flask 报错 RuntimeError: The session is unavailable because no secret key was set.
![[JS question solution] questions 1-10 in JS of niuke.com](/img/9d/4bae4a9a048e4e5412f157ec632c94.png)
[JS question solution] questions 1-10 in JS of niuke.com

微信小程序-组件传参,状态管理

Basic concepts of MySQL + database system structure + extended application + basic command learning

ClickHouse学习(三)表引擎
随机推荐
The function of using wechat applet to scan code to log in to the PC web of the system
虚拟增强与现实第二篇 (我是一只火鸟)
Summary of knowledge points related to forms and forms
Introduction to C language array to proficiency (array elaboration)
Clickhouse learning (VI) grammar optimization
Relationship between redrawing and reflow
ClickHouse学习(八)物化视图
Hcia-r & s self use notes (25) NAT technical background, NAT type and configuration
eggjs 创建应用知识点
Pointer
H5语义化标签
Basic concepts of MySQL + database system structure + extended application + basic command learning
全局components组件注册
rem与px与em异同点
记xx公司SQL注入漏洞
重绘与回流的关系
[sword finger offer] - explain the library function ATOI and simulate the realization of ATOI function
365 day challenge leetcode 1000 questions - day 035 one question per day + two point search 13
js简单代码判断打开页面的设备是电脑PC端或手机H5端或微信端
Detailed explanation of serial port communication