lit-html 和 lit-element 一起在html中使用代码
时间: 2024-05-31 18:07:09 浏览: 126
rollup-plugin-postcss-lit:在 LitElement 组件中加载 PostCSSed 样式表的 Rollup 插件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>LitHTML and LitElement Demo</title>
<script type="module">
import { html, LitElement } from 'https://unpkg.com/lit-element?module';
class MyElement extends LitElement {
static get properties() {
return {
name: { type: String }
};
}
constructor() {
super();
this.name = 'World';
}
render() {
return html`
<p>Hello, ${this.name}!</p>
`;
}
}
customElements.define('my-element', MyElement);
</script>
</head>
<body>
<my-element></my-element>
</body>
</html>
阅读全文