An easy way to use Web Components.
Only support ES6 module in browser.
import Yi from "./yi.js"
- write a
HelloWorld.html
file
<template>
<div>Hello <slot>world</slot></div>
</template>
the template file name must same with component name in order to load by Yi
2. write a HelloWorld.js
file
import Yi from '../src/yi.js'
export default class HelloWorld extends Yi {
}
- import and register your component in you ecmascript
<html>
<head></head>
<body>
<hello-world></hello-world>
<hello-world>Yi</hello-world>
<script type="module">
import HelloWorld from "./HelloWorld.js";
customElements.define('hello-world', HelloWorld)
</script>
</body>
</html>
you can see example in example
dir