在包装器组件中渲染了大约 300 个组件,并且需要花费大量时间来渲染。但我需要数千个组件才能在包装器容器内呈现。在渲染组件时如何在没有任何性能问题的情况下实现这一目标 Image shows the rendering time taken by 300 components which is too much
最佳答案
如果你有一个卷轴并且你的所有组件都不在 viewport 中同时,您可以使用Proxy Pattern
.
有一个名为 ember-in-viewport
的 ember 插件检测您的组件是否在视口(viewport)中。通过使用它,您可以实现代理模式。
这是一个sample twiddle .在 application.hbs
中,如果使用 my-proxy-component
而不是 my-component
,页面渲染速度将快近 3 倍。
关于javascript - 如何优化 Ember JS 中组件的渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41673206/