update demo
This commit is contained in:
parent
1946bafb70
commit
a3887992bd
|
@ -0,0 +1,55 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
|
||||
<meta charset="UTF-8" />
|
||||
<title>Omi demo without transpiler</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script src="https://tencent.github.io/omi/packages/omi/dist/omi.js"></script>
|
||||
<script>
|
||||
const { define, WeElement, html, render } = Omi
|
||||
|
||||
define('my-counter', class extends WeElement {
|
||||
initUse() {
|
||||
return ['count']
|
||||
}
|
||||
|
||||
install() {
|
||||
this.sub = this.sub.bind(this)
|
||||
this.add = this.add.bind(this)
|
||||
}
|
||||
|
||||
sub() {
|
||||
this.store.data.count--
|
||||
}
|
||||
|
||||
add() {
|
||||
this.store.data.count++
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`
|
||||
<div>
|
||||
<button onClick=${this.sub}>-</button>
|
||||
<span>${this.store.data.count}</span>
|
||||
<button onClick=${this.add}>+</button>
|
||||
</div>
|
||||
`}
|
||||
})
|
||||
|
||||
render(html`<my-counter />`, 'body', {
|
||||
data: {
|
||||
count: 1
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<a href="https://github.com/Tencent/omi" target="_blank" style="position: fixed; right: 0; top: 0; z-index: 3;">
|
||||
<img src="//alloyteam.github.io/github.png" alt="">
|
||||
</a>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -8,7 +8,7 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<script src="../../dist//omi.js"></script>
|
||||
<script src="https://tencent.github.io/omi/packages/omi/dist/omi.js"></script>
|
||||
<script>
|
||||
const { define, WeElement, html, render } = Omi
|
||||
|
||||
|
|
Loading…
Reference in New Issue