我正在使用 LitElement 创建一个 Web 组件。这是来自https://lit-element.polymer-project.org/guide/start
// Import the LitElement base class and html helper function
import { LitElement, html } from 'lit-element';
// Extend the LitElement base class
class MyElement extends LitElement {
/**
* Implement `render` to define a template for your element.
*
* You must provide an implementation of `render` for any element
* that uses LitElement as a base class.
*/
render(){
/**
* `render` must return a lit-html `TemplateResult`.
*
* To create a `TemplateResult`, tag a JavaScript template literal
* with the `html` helper function:
*/
return html`
<!-- template content -->
<p>A paragraph</p>
`;
}
}
// Register the new element with the browser.
customElements.define('my-element', MyElement);
如何在没有 Shadow DOM 的情况下创建 LitElement?