diff --git a/README.CN.md b/README.CN.md
index 259777318..17f74f1fa 100644
--- a/README.CN.md
+++ b/README.CN.md
@@ -268,7 +268,9 @@ render(, '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 (
- {this.count}
+ {this.data.count}
)
diff --git a/README.md b/README.md
index 4d488ec49..9193b5181 100644
--- a/README.md
+++ b/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 (
- {this.count}
+ {this.data.count}
)