【发布时间】:2019-04-09 10:13:08
【问题描述】:
我在 ASP.NET MVC 5 解决方案中通过 npm 安装了 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>
我的元素.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);
【问题讨论】:
-
文件可能不在您指定的位置 - 一个相对路径,一个固定的可能是这里的问题:localhost:64580/node_modules/lit-element/lit-element 应该是 localhost:64580/Scripts/node_modules/lit-element/lit-element.js 或类似的
-
找到解决方案了吗?
标签: javascript asp.net asp.net-mvc polymer-3.x lit-element