Skip to content

Instantly share code, notes, and snippets.

@nweldev
Last active March 2, 2019 00:06
Show Gist options
  • Save nweldev/916773366833a598f67ed7edfde3b96b to your computer and use it in GitHub Desktop.
Save nweldev/916773366833a598f67ed7edfde3b96b to your computer and use it in GitHub Desktop.
LitElement Hello World
/* Lit-element simply re-exports lit-html 'html' tag so that you don't have
* to care about it.
* See https://github.com/Polymer/lit-element/blob/v2.0.1/src/lit-element.ts#L21
*/
import { LitElement, html } from 'lit-element';
class HelloElement extends LitElement {
constructor() {
this.name = 'John';
}
render() {
return html`
<p>Hello ${this.name}!</p>
`;
}
}
/* In order to complete our Web Component definition, we need to define a Custom
* Element using this class as its constructor.
*/
customElements.define('hello-element', HelloElement);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment