lit-html 和 lit-element 一起在html中使用代码
时间: 2024-05-31 10:07:09 浏览: 123
<!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>
阅读全文