我已经在ASP.NET MVC5解决方案中通过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 (未找到)。
<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);发布于 2019-04-09 18:57:15
将import修改为
从lit-element导入{ LitElement,html };
发布于 2020-05-21 15:02:40
这可以解决这个问题。
像这样导入
import {
html,
LitElement,
} from 'https://unpkg.com/@polymer/lit-element@latest/lit-element.js?module';https://stackoverflow.com/questions/55590370
复制相似问题