前端vue less 主题颜色

  • 主题颜色
body{
  themeColor:#6faff1;
}
document.body.style.setProperty('themeColor', localStorage.getItem('themeColor'));
然后哪里需要用到主题背景色的用background: var(themeColor); 
  • 主题图
document.getElementsByClassName('el-header')[0].style.setProperty('background', "url(" + this.themeInData[++this.themeIndex].theme + ")")
//这是主题背景,注意这些背景需要先require引入
themeInData: [
          { theme: require('@/assets/theme1.jpg') }
]
  • 切换css
<link id="skin" href="default.css" rel="stylesheet" type="text/css">
document.getElementById('skin').href = 'red.css';
发布了122 篇原创文章 · 获赞 5 · 访问量 4842

猜你喜欢

转载自blog.csdn.net/weixin_41254345/article/details/104223238