我正在使用以下库:
- 角 4
- @ngrx/路由器商店
- @ngrx/store-devtools
就在最近,当尝试将设置为当前活动路由的go
路由器操作分派时:relativeTo
go(['test', id], {}, {relativeTo: this._active}))
我收到此错误:
ERROR TypeError: toISOString is not a function
at String.toJSON (<anonymous>)
at Object.<anonymous> (shim.js:736)
at derez (<anonymous>:2:5166)
at derez (<anonymous>:2:5787)
at derez (<anonymous>:2:5787)
at derez (<anonymous>:2:5787)
at derez (<anonymous>:2:5787)
at derez (<anonymous>:2:5605)
at derez (<anonymous>:2:5787)
at derez (<anonymous>:2:5787)
at derez (<anonymous>:2:5787)
at derez (<anonymous>:2:5787)
at derez (<anonymous>:2:5605)
at derez (<anonymous>:2:5787)
at derez (<anonymous>:2:5787)
处理有效负载中的 devtools 似乎存在问题ActivatedRoute
(类似于此问题)。
如果我实现了新版本的go
动作创建器(如此处建议:Redux Devtools Extension Troubleshooting)向 中添加一个toJSON
函数NavigationExtras
,那么一切正常:
go(path: string|any[], query?: any, extras?: NavigationExtras): any {
extras['toJSON'] = function(): any {
return { ...this, relativeTo: this.relativeTo.snapshot.url };
};
const payload = { path, query, extras };
return { type: routerActions.GO, payload };
}
有没有其他人遇到过这个问题?对于如何解决这个问题,有任何的建议吗?
更新:看起来它也与延迟加载的路由有关。仅当当前路由是延迟加载模块的一部分时才会发生错误(即 via loadChildren
)