Skip to content

实现换肤功能 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
LiuwqGit opened this issue Oct 24, 2017 · 0 comments
Open

实现换肤功能 #2

LiuwqGit opened this issue Oct 24, 2017 · 0 comments
Labels

Comments

@LiuwqGit
Copy link
Contributor

如何增加主题文件

说明:此项目UI是在elementUI基础上建立的,所以,我们可以通过element提供的方法,来自定义主题

生成自定义主题文件

使用工具下载自定义主题文件,并命名为wq-variables.css。以后我们如果想要增加主题文件,只需要修改变量文件中各个变量所对应的值。

编译主题

我们利用工具来编译主题。
在终端,将刚刚修改好的变量文件,通过命令node_modules/.bin/et -c wq-variables.css来编译主题。

给自定义主题增加命名空间

默认情况下,编译的主题目录会放在./theme下。由于,我们是通过改变css的命名空间来切换主题的,那么,我们就需要为刚生成的主题增加命名空间。主题文件内容很多,如果手动一个个添加命名空间,工作量巨大,这个时候,可以使用另一个给css增加命名空间的工具。下载这个项目(当然,也可以将这个工具集成到此项目中,但是我感觉没必要),然后只需要修改gulpfile.js文件中①②③3处内容,就可以得到想要的内容,这里注意,本项目css自定义的命名空间统一为custom-******,其中******建议使用主题色的16进制编码,也可以使用其他字符串,但是要和radio标签统一。

引用自定义主题

自定义主题文件,已经有了,只剩下如何引入使用了。

  • 在App.vue中import新增的主题样式
  • ./src/components/nav/topbar/topbar.vue中,添加对应的radio标签
    经过以上两步,就可以正常使用了。
@LiuwqGit LiuwqGit added the blog label Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant