当前位置:网站首页>Dynamically changing the style of label elements in a loop
Dynamically changing the style of label elements in a loop
2022-06-22 18:56:00 【Whirling and fluttering】
Dynamically change the style of the label element in the loop
Utilization cycle v-for Place tag elements on the page
<div v-for=(item,index) in list :key="index">{
{item}}/div>
list=[
'red','yellow','green','blue'
]
Set different class styles
.red{
color:red}
.yellow{
color:yellow}
.green{
color:green}
.blue{
color:blue}
Define objects to bind indexes ( Or other items , It needs to be decided ) Relationship with class style
const colorEnum={
red:{
class:'red'},
yellow:{
class:'yellow'},
green:{
class:'green'},
blue:{
class:'blue'},
}
Modify the class style in the label
<div v-for=(item,index) in list :key="index" :class="$$(colorEnum, [item], 'class')" >{
{item}}/div>
Effect view

Code instructions
explain : The code is written in vue In the frame
Key sentences :class="$$(colorEnum, [item], 'class')" // Add two. $ To dynamically match item and colorEnum Key in the corresponding object in class Value .
边栏推荐
- Linked list 4- 21 merge two ordered linked lists
- Jenkins installation and upgrade
- Exness sorted out three problems to be solved in Musk's acquisition of Twitter
- Golang实现基于Redis的可靠延迟队列
- 【工具】pip和conda的相關使用
- azkaban启动报错 2022/06/20 21:39:27.726 +0800 ERROR [StdOutErrRedirect] [Azkaban] Exception in thread “m
- How does flynk MySQL CDC guarantee the server_ Is the ID globally unique?
- Set of redis data structure
- Mise en œuvre de redis par golang (10): transactions atomiques locales
- The Jenkins container failed to install the ruby runtime plug-in. Solve the error
猜你喜欢

大一女生废话编程爆火!懂不懂编程的看完都拴Q了

Nuxt - Universal (SSR / SSG) / single page app (rendering mode)

写一本畅销书是怎样的一种体验

JVM快速入门

零基础学编程/学逆向/过检测(frida实战)

The world's first AR contact lens, the entrance of metauniverse is really opened this time?

Zero basic programming / reverse learning / over detection (Frida practice)

@“齐鲁多娇”幸运用户,山东5A景区喊你免费游园啦!

阿里云过户找不到账号安全组ID问题

C sqlsugar, hisql, FreeSQL ORM framework omni-directional performance test comparison sqlserver
随机推荐
Jenkins中node节点添加之SSH方式2
@“齐鲁多娇”幸运用户,山东5A景区喊你免费游园啦!
Jenkins installation and upgrade
Live broadcast Preview - 12 first-class Chinese scholars open ICLR 2022
各位大佬,第一次使用flink mysql cdc, 现在程序启动 没报错 新增数据没有打印出来
At 19:30 today, the science popularization leader said that he would take you to explore how AI can stimulate human creativity
腾讯云国际版云服务器欠费说明
Activity跳转到Fragment的方法(Intent)
自定义数据库连接池类: 要求:封闭一个Collection对象的集合类
第四届青年生命科学论坛 | 第一轮通知
2022年G2电站锅炉司炉题库及在线模拟考试
Explain the startup process of opengauss multithreading architecture in detail
Centeros install mangodb
详解openGauss多线程架构启动过程
A course for New Oriental transformation bilingual live broadcast to bring goods to the project manager
Does CDC 2.2.1 monitoring sqlserver not support monitoring multiple databases?
Jenkins配置项目集成钉钉通知
ADAU1452开发系统界面与代码数据之间的关系
<JVM上篇:内存与垃圾回收篇>08-对象实例化及直接内存
jsp连接MySQL总出错