1. Install create-element-class
npm install create-element-class --save
import createElementClass from 'create-element-class'
const HelloWorld = createElementClass({
connectedCallback() {
this.innerHTML = 'Hello, world!'
}
})
customElements.define('hello-world', HelloWorld)
<hello-world></hello-world>
npm install @webcomponents/custom-elements --save-dev
import '@webcomponents/custom-elements'
Or:
<script src="https://unpkg.com/@webcomponents/[email protected]"></script>
- Custom Elements v1: Reusable Web Components, by Eric Bidelman
- Reintroducing Custom Elements V1, by Andrea Giammarchi
- The Case for Custom Elements: Part 1, by Rob Dodson