当前位置: 首页 > news >正文

html通过数据改变,图片跟着改变

改变前 

 改变后

通过数据来控制样式展示 

<template><div>通过num控制图标是否更改{{num}}<div class="box"><!-- 如果num大于1则是另一种,样式,如果小时1,则是另一种样式 --><div class="item" :class="num > 1 ? 'noClick' :''" v-for="(item,index) in menuData" :key="index"><div class="img" :class="item.icon"></div><div class="content">{{item.name}}</div><div class="arrow"><img src="../assets/evaluateOthers/role-arrow.png" alt=""></div></div></div></div>
</template><script>
export default {data () {return {num: 10,menuData: [{name: '学不会1',icon: 'other'},{name: '学不会2',icon: 'my'},{name: '学不会3',icon: 'people'},{name: '学不会4',icon: 'shaicha'}]}}
}
</script><style lang="less" scoped>
.box {padding: 20px;
}
.item {background: #ffffff;box-shadow: 0px 1px 5px 1px rgba(0, 0, 0, 0.11);border-radius: 4px;width: 100%;margin-bottom: 16px;padding: 18px 17px 18px 20px;box-sizing: border-box;display: flex;align-items: center;position: relative;
}
.img {width: 44px;height: 44px;margin-right: 17px;&.other {background: url('../assets/evaluateOthers/other-icon.png') no-repeat center;background-size: 44px;}&.my {background: url('../assets/evaluateOthers/my-icon.png') no-repeat center;background-size: 44px;}&.people {background: url('../assets/evaluateOthers/people-icon.png') no-repeat center;background-size: 44px;}&.shaicha {background: url('../assets/evaluateOthers/shaicha.png') no-repeat center;background-size: 44px;}
}
// 符合条件后带的样式
.noClick {.img {&.other {background: url('../assets/evaluateOthers/no-other-icon.png') no-repeatcenter;background-size: 44px;}&.my {background: url('../assets/evaluateOthers/wartfor.png') no-repeat center;background-size: 44px;}&.people {background: url('../assets/evaluateOthers/people-icon.png') no-repeatcenter;background-size: 44px;}&.shaicha {background: url('../assets/evaluateOthers/shaicha.png') no-repeat center;background-size: 44px;}}
}
.arrow {position: absolute;right: 14px;top: 50%;transform: translate(0, -50%);
}
</style>

http://www.lryc.cn/news/353087.html

相关文章:

  • centos7.9 安装SqlServer
  • Idea中flume的Interceptor的编写教程
  • java单元测试:JUnit测试运行器
  • 网络模型—BIO、NIO、IO多路复用、信号驱动IO、异步IO
  • 智能语义识别电影机器人的rasa实现
  • C# 实现腾讯云 IM 常用 REST API 之会话管理
  • MySQL之Schema与数据类型优化(三)
  • 大语言模型发展历史
  • Nginx - 安全基线配置与操作指南
  • 简述js的事件循环以及宏任务和微任务
  • [力扣题解] 797. 所有可能的路径
  • 【QT八股文】系列之篇章3 | QT的多线程以及QThread与QObject
  • 基于python flask的web服务
  • HTTP 响应分割漏洞
  • Algoriddim djay Pro Ai for Mac:AI引领,混音新篇章
  • 常见算法(3)
  • 集中抄表电表是什么?
  • 第八届能源、环境与材料科学国际学术会议(EEMS 2024)
  • 09.自注意力机制
  • 时政|杂粮产业
  • docker 安装 私有云盘 nextcloud
  • 第十一届蓝桥杯物联网试题(国赛)
  • 算法金 | Dask,一个超强的 python 库
  • Java 说唱歌手
  • 面试-软件工程与设计模式相关,Spring简介
  • IDEA中一些常见操作【持续更新】
  • java继承使用细节二
  • c++11 标准模板(STL)本地化库 - 平面类别(std::numpunct_byname) 表示系统提供的具名本地环境的 std::numpunct
  • XILINX FPGA DDR 学习笔记(一)
  • vue源码2