Skip to content

Instantly share code, notes, and snippets.

@magic-akari
Last active February 23, 2019 17:59
Show Gist options
  • Save magic-akari/b3f84546d947a78c0831b5ace0e40540 to your computer and use it in GitHub Desktop.
Save magic-akari/b3f84546d947a78c0831b5ace0e40540 to your computer and use it in GitHub Desktop.

Lit-element test

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>LitElement Demo</title>
<script src="./index.js" type="module"></script>
</head>
<body>
<app-demo></app-demo>
</body>
</html>
import {
LitElement,
html
} from "https://unpkg.com/[email protected]/lit-element.js?module";
import { repeat } from "https://unpkg.com/[email protected]/directives/repeat.js?module";
customElements.define(
"app-demo",
class extends LitElement {
constructor() {
super();
this.data = Array.from(Array(10).keys()).map(v => ({
id: v,
value: v * v
}));
}
render() {
return html`
<section>
${repeat(
this.data,
data => data.id,
data =>
html`
<p>${data.value}</p>
`
)}
</section>
`;
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment