kittencup / angular2-ama-cn

angular2 随便问
692 stars 101 forks source link

Angular 2 中路由状态保持的问题? #220

Open lijiakof opened 7 years ago

lijiakof commented 7 years ago

在使用 angular 2 的过程中,采用了 SPA,这样在页面跳转的过程中会有一些路由状态无法保持的问题:

这种每次都从头加载,没有保持路由当前数据和显示状态在体验上非常差,能否有一个系统的解决方案来解决这个问题。

bigggge commented 7 years ago

+1 求方法

hstarorg commented 7 years ago

这个的话,可能需要自己实现方法来处理,可以考虑提供一个公共方法,每次进入组件时,进行 restore

niboac commented 7 years ago

用RouteReuseStrategy可以实现, 请google: angular2 RouteReuseStrategy, 参考:https://www.softwarearchitekt.at/post/2016/12/02/sticky-routes-in-angular-2-3-with-routereusestrategy.aspx

RockNHawk commented 6 years ago

参考这篇最高赞回答 https://stackoverflow.com/questions/41280471/how-to-implement-routereusestrategy-shoulddetach-for-specific-routes-in-angular