update readme

This commit is contained in:
dntzhang 2018-11-07 09:11:29 +08:00
parent 404466858b
commit 42515d8520
2 changed files with 32 additions and 0 deletions

View File

@ -631,6 +631,22 @@ define("my-app", class extends WeElement {
因为 data 设置只会简单对比前后的值,复杂对象不会深对比,对比值不同会触发 update update 会触发上面函数,就无限递归了。
举例说明:
❌错误方式:
```js
beforeRender(){
this.data.a = { b: 1 }
}
```
✅ 正确方式:
```js
beforeRender(){
this.data.a.b = 1
}
```
如果你想要兼容 IE11,请使用 `omi-mobx` 代替 omi 自带的 observe往下看..
### Omi Mobx

View File

@ -631,6 +631,22 @@ It should be noted that if `observe` is used, do not set the value of data in so
Because data settings will simply compare the value before and after, complex objects will not be deep contrast, the contrast value will trigger different update, update will trigger the above function, infinite recursion.
For Example:
❌Wrong way:
```js
beforeRender(){
this.data.a = { b: 1 }
}
```
✅ Right way:
```js
beforeRender(){
this.data.a.b = 1
}
```
If you want to be compatible with IE11, please use the `omi-mobx` instead of omi's own observe.
### Omi Mobx