速度与性能
Angular 2 比 Angular 1 快得多,它支持通过服务器端预渲染实现快速初始加载、用于快速启动的离线编译以及用于平滑虚拟滚动和快速视图转换的超快更改检测和视图缓存。
这些功能看起来很棒,但一个正常的要求是,当我从 导航ListComponent到 时ViewComponent,我希望保留ListComponent缓存,所以当我从 中单击返回时ViewComponent,ListComponent不需要重新渲染(ListComponent通常从第 2、3 页等获取 AJAX 数据。我知道我可以将数据保存在服务中并scrollPosition在单击返回时存储,但它会再次重新呈现数据。我真的认为缓存它是一种更好的方法。
我实现CanReuse了 ,但它不起作用,它只在 . 之间导航时起作用ViewComponents。ListComponent所以,我想知道ViewComponent缓存是如何工作的。