当前位置:网站首页>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 .
边栏推荐
- Nuxt - create nuxt app
- 项目经理们在哪个时刻特别想逃离工作?
- 利用Inkscape转换为dxf文件的正确方法 svg导出dxf文件
- Concepts and solutions of redis' cache penetration, cache avalanche and cache breakdown problems
- 2022年R2移动式压力容器充装试题模拟考试平台操作
- Nuxt - Universal (SSR / SSG) / single page app (rendering mode)
- How can I automatically make an appointment to make a new debt? Is it convenient and safe to make an appointment to make a new bond
- In May, 2022, China's game manufacturers and applications went to sea, with top 30 revenue in EMEA region
- jsp连接MySQL总出错
- Is it safe for Ping An Securities to open an account? What is its relationship with Ping An Bank?
猜你喜欢

Nuxt - Universal(SSR / SSG)/ Single Page App(渲染模式)

直播预告 | 12位一作华人学者开启 ICLR 2022

The Fourth Youth Life Science Forum | first round notice

Correct method of converting Inkscape into DXF file SVG exporting DXF file

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

What is the experience of writing a best seller

What happened to this page when sqlserver was saving

Grafana 9 正式发布,更易用,更酷炫了!

2022年5月中国游戏厂商及应用出海 EMEA 地区收入30强
Oracle中dbms_output.put_line的用法实例
随机推荐
CONDA - basic configuration command summary
链表4- 21 合并两个有序链表
Exness sorted out three problems to be solved in Musk's acquisition of Twitter
The Jenkins container failed to install the ruby runtime plug-in. Solve the error
线程池:ThreadPoolExcutor源码阅读
@Lucky user of "Qilu Duojiao", Shandong 5A scenic spot calls you to visit the park for free!
Is it safe for Ping An Securities to open an account? What is its relationship with Ping An Bank?
传统图像--LBP特征
Plan and change of continuous repair
Correct method of converting Inkscape into DXF file SVG exporting DXF file
Array implementation of circular linked list
d的dip1000,1
wpa_supplicant的状态机迁移
High voltage direct current (HVDC) model based on converter (MMC) technology and voltage source converter (VSC) (implemented by MATLAB & Simulink)
sqlserver保存时遇到这个页面怎么回事啊
数据库行业分析:从全球IT产业趋势到国产数据库发展之路
传输层 知识点总结
Babbitt | yuancosmos daily must read: it is said that Tencent has established XR department, and yuancosmos sector has risen again. Many securities companies have issued reports to pay attention to th
预训练语言模型,bert,RoFormer-Sim又称SimBERTv2
Custom database connection pool class: requirement: enclose the collection class of a collection object