update readme

This commit is contained in:
张磊 2018-12-20 10:53:30 +08:00
parent e7cc2c12df
commit 4aad46810a
1 changed files with 48 additions and 4 deletions

View File

@ -8,10 +8,10 @@
* `create.Page(option)` 创建页面
* `create.Component(option)` 创建组件
* `create.mitt()` 事件发送和监听器
* `create.emitter` 事件发送和监听器
* `this.oData` 操作页面或组件的数据(会自动更新视图)
* `this.store` 页面注入的 store页面和页面所有组件可以拿到
* `create.mitt()` 事件发送和监听器
* `create.emitter` 事件发送和监听器,不同于 mitt() 每次会创建新的实例emitter 是全局唯一,可以用于跨页面通讯
### 实战
@ -160,10 +160,54 @@ emitter.off('foo', onFoo) // unlisten
```
[详细参见 mitt github](https://github.com/developit/mitt)
<!--
## 原理
## Todo
最开始 `omi-mp-create` 打算使用 proxy但是调研了下兼容性还是打算使用 obaa 来进行数据变更监听。
因为小程序 IOS 使用内置的 jscore安卓使用 x5所以 Proxy 兼容性(IOS10+支持,安卓基本都支持)
![](https://github.com/Tencent/westore/raw/master/asset/ios.jpg)
实时统计地址https://developer.apple.com/support/app-store/
```js
this.setData({
logs: [1, 2, 3]
})
setTimeout(() => {
this.setData({
'logs[2]': null
})
}, 2000)
setTimeout(() => {
console.log(this.data.logs.length)
}, 3000)
```
#### 页面生命周期函数
| 名称 | 描述 |
| ------ | ------ |
| onLoad | 监听页面加载 |
| onShow | 监听页面显示 |
| onReady | 监听页面初次渲染完成 |
| onHide | 监听页面隐藏 |
| onUnload | 监听页面卸载 |
### 组件生命周期函数
| 名称 | 描述 |
| ------ | ------ |
| created | 在组件实例进入页面节点树时执行,注意此时不能调用 setData |
| attached | 在组件实例进入页面节点树时执行 |
| ready | 在组件布局完成后执行,此时可以获取节点信息(使用 SelectorQuery |
| moved | 在组件实例被移动到节点树另一个位置时执行 |
| detached | 在组件实例被从页面节点树移除时执行 | -->
* supports function props
## 谁在使用