-
Notifications
You must be signed in to change notification settings - Fork 69
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
大佬,请问一下如何保证动态主题的style标签永远在head标签内最后一个呢 #15
Comments
要保证这个做什么,意义何在? |
呃呃呃,异步加载的组件会产生新的style标签样式,然后就被后面的样式覆盖了,然后样式就不生效了 |
你是说css被覆盖了?这个目前有个方案是在颜色的样式前加一个 body ,通过changeSelector配置 |
嗯嗯,异步加载的组件会产生新的style标签,然后覆盖动态主题style标签内的样式。我现在是改了下源码,把head改成body,下面是我的配置 |
之前的方案是这样:https://github.com/hzsrc/webpack-theme-color-replacer/blob/master/forElementUI/index.js 思路是把主题色样式的优先级提高,使之不会被覆盖。不过有时候会导致优先级提升过度的问题。 |
放body里面大多数浏览器都没有问题,但是不符合规范,使用changeSelector已经可以了,多谢大佬 |
@iota9star 我测试过了,你说的这个方案比我说的提升优先级的方法好,我已经把插件代码升级了。使用 |
@hzsrc 干的漂亮 |
放body下是目前解决优先级问题的最佳方案。你说的问题确实也存在,如果项目没有优先级问题的话,可以通过一个 appendToEl: 'head'选项来附加到head中。另外,injectCss: true 这个选项也可以尝试下,或许对你的项目有用。
…------------------ 原始邮件 ------------------
发件人: "yangdongMC"<[email protected]>;
发送时间: 2020年1月8日(星期三) 下午2:04
收件人: "hzsrc/webpack-theme-color-replacer"<[email protected]>;
抄送: "5953107"<[email protected]>; "Mention"<[email protected]>;
主题: Re: [hzsrc/webpack-theme-color-replacer] 大佬,请问一下如何保证动态主题的style标签永远在head标签内最后一个呢 (#15)
append 到body 下面,有个很严重的视觉体验问题,强刷浏览器,颜色过渡替换的那么明显。
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
因为是异步组件,异步组件加载以后会新增style标签,然后覆盖之前的动态主题的style标签样式
我想到的办法:
The text was updated successfully, but these errors were encountered: