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

js替换css主题变量并切换iconfont文件

iconfont不止有单色、双色的图标,还有很多【多色】的图标,于是不能【去色】,只能手动替换primary

新建一个iconfont,替换过主题色的,然后与旧的iconfont配合切换使用

主要如下:

reqiure之前必须【清除缓存】,否则无法生效,require加载机制如上图所示

const onChangeYellow = (index) => {if (appPrimary.value === "yellow") {// 重新设置主题色document.getElementsByClassName("skin-variant--semi-dark")[0].style.setProperty("--v-primary-base", "#EDE20B");document.getElementsByClassName("v-main")[0].style.setProperty("--v-primary-base", "#323232");vm.$vuetify.theme.themes.dark.primary = "#323232";// document.getElementsByTagName('html')[0].className = appPrimary.valuedocument.documentElement.className = appPrimary.value;// 清除缓存delete require.cache[require.resolve("@/assets/yellow-iconfont/iconfont")];delete require.cache[require.resolve("@/assets/yellow-iconfont/iconfont.css")];// 引入新的iconfont文件require("@/assets/yellow-iconfont/iconfont");require("@/assets/yellow-iconfont/iconfont.css");} else {document.getElementsByClassName("skin-variant--semi-dark")[0].style.removeProperty("--v-primary-base");document.getElementsByClassName("v-main")[0].style.removeProperty("--v-primary-base");// document.getElementsByTagName('html')[0].className = ''document.documentElement.className = "";// document.getElementsByClassName('yellow-iconfont')[0].remove()delete require.cache[require.resolve("@/assets/iconfont/iconfont")];delete require.cache[require.resolve("@/assets/iconfont/iconfont.css")];require("@/assets/iconfont/iconfont");require("@/assets/iconfont/iconfont.css");}
};
http://www.lryc.cn/news/449592.html

相关文章:

  • UI设计师面试整理-设计趋势和行业理解
  • Java零工市场小程序如何改变自由职业者生活
  • android11 自动授权访问sdcard
  • 优青博导团队/免费指导/数据分析//论文润色/组学技术服务 、表观组分析、互作组分析、遗传转化实验、生物医学
  • Mybatis 学习之 分页实现
  • Spring Boot文件上传
  • 基于Springboot+Vue的高校体育运动会比赛系统(含源码+数据库)
  • 【JavaEE】——内存可见性问题
  • YOLO训练参数设置解析
  • 基于OpenCV的实时年龄与性别识别(支持CPU和GPU)
  • 理解Js执行上下文
  • 微信小程序 蓝牙通讯
  • java后端项目技术记录
  • PostgreSQL数据库与PostGIS在Windows中的部署与运行
  • 高级算法设计与分析 学习笔记10 平摊分析
  • 从“纸面算力”到“好用算力”,超聚变打通AI+“最后一公里”
  • 【有啥问啥】具身智能(Embodied AI):人工智能的新前沿
  • 11-pg内核之锁管理器(六)死锁检测
  • Git 与标签管理
  • 【0334】Postgres内核之 auxiliary process(辅助进程)初始化 MyPgXact
  • 20.1 分析pull模型在k8s中的应用,对比push模型
  • Ubuntu 镜像替换为阿里云镜像:简化你的下载体验
  • The Sandbox 游戏制作教程第 6 章|如何使用装备制作出色的游戏 —— 避免环境危险
  • JavaScript中的输出方式
  • 力扣9.25
  • 从零开始之AI面试小程序
  • Html2OpenXml:HTML转化为OpenXml的.Net库,轻松实现Html转为Word。
  • HumanNeRF:Free-viewpoint Rendering of Moving People from Monocular Video 精读
  • Springboot中基于注解实现公共字段自动填充
  • Android 已经过时的方法用什么新方法替代?