Lit-element test
Last active
February 23, 2019 17:59
-
-
Save magic-akari/b3f84546d947a78c0831b5ace0e40540 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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