wechat-miniprogram / wechat-miniprogram/computed
computed 和 watch 不会在自定义组件或页面卸载时自动移除监听吗?
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 696
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
Description
在写业务逻辑时,发现computed 和 watch 并不会在自定义组件或页面卸载时自动移除监听,如果watch内部使用了this,也就是当前组件实例或页面实例,则该实例不会被释放,如果多次进入同一页面,watch监听会重复绑定多个,严重影响性能和业务逻辑。
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by tracing where computed and watch listeners are registered, then reproduce repeated entry and exit from the same page or custom component. Done means listeners are removed on unload, repeated visits do not multiply watchers, and instances using this can be released.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100