update readme
This commit is contained in:
parent
a7fab92ee4
commit
e98ffdaf82
10
README.CN.md
10
README.CN.md
|
@ -268,7 +268,9 @@ render(<my-counter />, 'body')
|
|||
import { render, WeElement, define } from 'omi'
|
||||
|
||||
define('my-counter', class extends WeElement {
|
||||
count = 1
|
||||
data = {
|
||||
count: 1
|
||||
}
|
||||
|
||||
//也可以直接传递字符串
|
||||
css = `span{
|
||||
|
@ -276,12 +278,12 @@ define('my-counter', class extends WeElement {
|
|||
}`
|
||||
|
||||
sub = () => {
|
||||
this.count--
|
||||
this.data.count--
|
||||
this.update()
|
||||
}
|
||||
|
||||
add = () => {
|
||||
this.count++
|
||||
this.data.count++
|
||||
this.update()
|
||||
}
|
||||
|
||||
|
@ -289,7 +291,7 @@ define('my-counter', class extends WeElement {
|
|||
return (
|
||||
<div>
|
||||
<button onClick={this.sub}>-</button>
|
||||
<span>{this.count}</span>
|
||||
<span>{this.data.count}</span>
|
||||
<button onClick={this.add}>+</button>
|
||||
</div>
|
||||
)
|
||||
|
|
10
README.md
10
README.md
|
@ -248,7 +248,9 @@ You can also update the view manually then you can choose the best time to updat
|
|||
import { render, WeElement, define } from 'omi'
|
||||
|
||||
define('my-counter', class extends WeElement {
|
||||
count = 1
|
||||
data = {
|
||||
count: 1
|
||||
}
|
||||
|
||||
//You can also pass strings directly
|
||||
css = `span{
|
||||
|
@ -256,12 +258,12 @@ define('my-counter', class extends WeElement {
|
|||
}`
|
||||
|
||||
sub = () => {
|
||||
this.count--
|
||||
this.data.count--
|
||||
this.update()
|
||||
}
|
||||
|
||||
add = () => {
|
||||
this.count++
|
||||
this.data.count++
|
||||
this.update()
|
||||
}
|
||||
|
||||
|
@ -269,7 +271,7 @@ define('my-counter', class extends WeElement {
|
|||
return (
|
||||
<div>
|
||||
<button onClick={this.sub}>-</button>
|
||||
<span>{this.count}</span>
|
||||
<span>{this.data.count}</span>
|
||||
<button onClick={this.add}>+</button>
|
||||
</div>
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue