【发布时间】:2019-08-02 11:41:17
【问题描述】:
我正在做一个 lit-element 项目,我遇到了一个问题,reset.css 无法应用于使用 shadow-root 包装的 Web 组件
我尝试过这种方式,但出现以下错误。
Refused to apply style from 'http://localhost:8080/style/static/reset.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
我试过的代码是这样的:
<script>
var css = new CSSStyleSheet()
css.replace('@import url("./style/static/reset.css")')
document.adoptedStyleSheets = [css]
</script>
这被放入一个 html 文件中。
如何避免此错误,并将 reset.css 应用于 Web 组件?
【问题讨论】:
-
其实应该可以的。错误来自其他地方(可能是您的 Web 服务器设置了错误的 MIME 类型)
标签: polymer web-component shadow-dom lit-element lit-html