61 lines
1.1 KiB
HTML
Executable File
61 lines
1.1 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
|
|
<meta charset="UTF-8" />
|
|
<title>Omi</title>
|
|
</head>
|
|
|
|
<body>
|
|
<script src="https://unpkg.com/omi"></script>
|
|
<script>
|
|
const {
|
|
define,
|
|
render,
|
|
h
|
|
} = Omi
|
|
|
|
class Store {
|
|
data = {
|
|
count: 1
|
|
}
|
|
sub = () => {
|
|
this.data.count--
|
|
}
|
|
add = () => {
|
|
this.data.count++
|
|
}
|
|
}
|
|
|
|
define('my-counter', _ => (
|
|
h(h.f, null,
|
|
h('button', {
|
|
onClick: _.store.sub
|
|
}, '-'),
|
|
h('span', null, _.store.data.count),
|
|
h('button', {
|
|
onClick: _.store.add
|
|
}, '+')
|
|
)
|
|
), {
|
|
use: ['count'],
|
|
//or using useSelf, useSelf will update self only, exclude children components
|
|
//useSelf: ['count'],
|
|
css: `span { color: red; }`,
|
|
installed() {
|
|
console.log('installed')
|
|
}
|
|
})
|
|
|
|
render(h('my-counter'), 'body', new Store)
|
|
|
|
</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>
|