update readme

This commit is contained in:
张磊 2018-10-29 09:24:19 +08:00
parent 1f6643124b
commit 867bbd6bbc
1 changed files with 41 additions and 0 deletions

View File

@ -35,6 +35,7 @@
- [Omi 生态](#omi-生态)
- [一个 HTML 完全上手](#一个-html-完全上手)
- [再花 30 秒完全上手](#再花-30-秒完全上手)
- [快速入门](#快速入门)
- [安装](#安装)
- [Hello Element](#hello-element)
@ -132,6 +133,46 @@
</body>
```
## 再花 30 秒完全上手
你也可以使用现代化的 JS 语法,快速构建 Omi 项目:
```js
import { render, WeElement, tag, observe } from "omi"
@observe
@tag("my-counter")
class MyApp extends WeElement {
install() {
this.data.count = 0
}
sub = () => {
this.data.count--
}
add = () => {
this.data.count++
}
render() {
return (
<div>
<button onClick={this.sub}>-</button>
<span>{this.data.count}</span>
<button onClick={this.add}>+</button>
</div>
)
}
}
render(<my-counter />, "body")
```
[→ counter demo](https://tencent.github.io/omi/packages/omi/examples/counter/)
## 快速入门
### 安装