首页 > 解决方案 > 在聚合物中导入样式表

问题描述

我正在尝试从 Polymer 2.0 的库中导入样式表,虽然它在我的本地环境中工作,但当我将它部署到 firebase 托管时它失败了。这就是我所拥有的。

  <!-- for the tree view of the lesson -->
  <link rel="stylesheet" href="/node_modules/json-view/dist/jsonview.bundle.css" />

  <dom-module id="my-admin-lesson-v2">
    <template></template>

当我在 Firefox 中运行它时,我收到了这个错误(我在 Chrome 中没有看到它,但是 Chrome 稍后在我导入 .js 文件时失败了。所以在我看来类似的问题)。

The stylesheet https://c3do-classroom.web.app/node_modules/json-view/dist/jsonview.bundle.css was not loaded because its MIME type, “text/html”, is not “text/css”. admin-lesson-v2

看来该错误是由于 SPA 文件被导入并被视为 html 引起的,因为它在我的 index.html 文件中显示它失败。如何正确导入 css 和 js 文件?

标签: javascriptpolymerpolymer-2.x

解决方案


推荐阅读