Akryum / Akryum/vue-9-perf-secrets
We may use computed property instead of child component splitting?
- 主要语言
- Vue
- 星标
- 556
- 派生
- 78
- PR 合并指标
- 30 天内没有已合并 PR
描述
First, thanks for the awesome Project!
In the `Child component splitting` demo,the root cause of the performance problem is that we use `heavy` function during render, it will also be called when the component render.
Instead of using child component splitting, can we use computed property? For example:
```
export default {
props: ['number'],
computed: {
heavy () {
const n = 100000
let result = 0
for (let i = 0; i < n; i++) {
result += Math.sqrt(Math.cos(Math.sin(42)))
}
return result
}
}
}
```
Because create a child component will have some extra overhead, so computed property here is better ? Computed property will use cache if it's dependencies not change, and I think we should use computed property as much as possible other than method, unless in some special cases.
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。