我已经通过 npm 在 ASP.NET MVC 5 解决方案中安装了 lit-element。我正在尝试创建一个启动器 标签如 https://lit-element.polymer-project.org/guide/start 中所述指导。在浏览器中,我在 Chrome 中收到“GET http://localhost:64580/node_modules/lit-element/lit-element” net::ERR_ABORTED 404 (Not Found)。
<head>
<script src="~/Scripts/my-element.js" type="module"></script>
</head>
<body>
<my-element></my-element>
</body>
my-element.js
import { LitElement, html } from "../node_modules/lit-element/lit-element";
class MyElement extends LitElement {
render() {
return html`
<!-- template content -->
<p>A paragraph</p>
`;
}
}
customElements.define('my-element', MyElement);
最佳答案
修改导入
为
从“lit-element”导入 { LitElement, html };
关于JavaScript 导入 lit-element 在浏览器中出现 404 未找到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55590370/