- 主题颜色
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';