Skip to content

Commit b87bae7

Browse files
committed
feat: 完善behavior注入能力
1 parent b0a0948 commit b87bae7

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@ ComponentWithComputed({
156156

157157
(类似地,也有 `BehaviorWithComputed` 构造器对应于 `Bahavior` 。)
158158

159+
**注意:当使用 `ComponentWithComputed` 或者 `BehaviorWithComputed` 的时候,要留意 `computedBehavior` 的加入时机**
160+
161+
`computedBehavior` 会通过 `unshift` 方法加入到 `behaviors` 的开始位置,如果需要在加入 `computedBehavior` 之前加入其他的 behavior,需要通过 `behaviorsBeforeComputed` 属性加入,如:
162+
163+
```ts
164+
import { ComponentWithComputed } from 'miniprogram-computed'
165+
166+
ComponentWithComputed({
167+
behaviors: ['b'],
168+
behaviorsBeforeComputed: ['a'],
169+
})
170+
```
171+
172+
最终会将behaviors处理成:`['a', 'computedBehavior', 'c']`
173+
159174
**关于 TS 兼容问题**
160175

161176
若在小程序中用 `TypeScript` 进行开发并使用到了 `Component` 构造器。这时定义 `computed``watch` 字段会出现类型报错。

dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)