omip - update readme

This commit is contained in:
dntzhang 2019-02-26 20:12:59 +08:00
parent c01bc349fa
commit a7fab92ee4
2 changed files with 34 additions and 5 deletions

View File

@ -21,6 +21,39 @@ npm start
把小程序目录设置到 dist 目录就可以愉快地调试了!
## 代码示例
```js
import { WeElement, define } from 'omi'
import './index.css'
define('my-counter', class extends WeElement {
data = {
count: 1
}
sub = () => {
this.data.count--
this.update()
}
add = () => {
this.data.count++
this.update()
}
render() {
return (
<view>
<button onClick={this.sub}>-</button>
<text>{this.data.count}</text>
<button onClick={this.add}>+</button>
</view>
)
}
})
```
## License
MIT © dntzhang

View File

@ -9,10 +9,6 @@ define('my-counter', class extends WeElement {
count: 1
}
css = `span{
color: red;
}`
sub = () => {
this.data.count--
this.fire('change', this.data.count)
@ -35,4 +31,4 @@ define('my-counter', class extends WeElement {
</view>
)
}
})
})