我正在使用角4(angular-router@4.4.6); 我有一个类似Instagram的帖子网格和时间轴,我想在从帖子等回来后记住滚动点,... 我使用下面显示的customRouteReuseStrategy,但它会产生不可预测的行为
任何人都可以给我一个解决方案或替代方案吗? 感谢
private handlers: { [key: string]: DetachedRouteHandle } = {};
constructor() {
}
shouldDetach(route: ActivatedRouteSnapshot): boolean {
return true;
}
store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle): void {
this.handlers[route.url.join("/") || route.parent.url.join("/")] = handle;
}
shouldAttach(route: ActivatedRouteSnapshot): boolean {
return !!this.handlers[route.url.join("/")];
}
retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle {
return this.handlers[route.url.join("/") || route.parent.url.join("/")];
}
shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {
return future.routeConfig === curr.routeConfig;
}