I have installed lit-element via npm in ASP.NET MVC 5 solution. I am trying to create a starter tag as described in https://lit-element.polymer-project.org/guide/start guide. In browser, I get "GET http://localhost:64580/node_modules/lit-element/lit-element " net::ERR_ABORTED 404 (Not Found) in chrome.
<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);
Modify import
as
import { LitElement, html } from "lit-element";
This can resolve this issue
Import like this
import {
html,
LitElement,
} from 'https://unpkg.com/@polymer/lit-element@latest/lit-element.js?module';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.