Angular7:flatMap不是函数
Angular 7: flatMap is not a function
我正在从 angular 5
迁移到 angular 7
,当我在 npm start
.
时遇到此错误
const config = this.router.events.pipe(
skipWhile(() => !this.router.navigate),
take(1),
flatMap(() => this.route.queryParams.pipe(take(1)).flatMap(params => {
其他详情如下:
private route: ActivatedRouter
private router: Router
rxjs version is ^6.3.3
用MergeMap
替换flatMap
是个不错的选择吗?如果是这样,我是否也需要更改代码?我该怎么办?
您需要像在 take(1)
中那样在 pipe
运算符中添加 flatMap
试试这个:
this.route.queryParams.pipe(take(1), flatMap(params => {
})
是的,用 mergeMap 替换 flatMap 是一个不错的选择,因为它们是同一件事。在某些时候,flatMap 被重命名为 mergeMap。如果您使用 mergeMap,则无需对代码进行任何更改。
我正在从 angular 5
迁移到 angular 7
,当我在 npm start
.
const config = this.router.events.pipe(
skipWhile(() => !this.router.navigate),
take(1),
flatMap(() => this.route.queryParams.pipe(take(1)).flatMap(params => {
其他详情如下:
private route: ActivatedRouter
private router: Router
rxjs version is ^6.3.3
用MergeMap
替换flatMap
是个不错的选择吗?如果是这样,我是否也需要更改代码?我该怎么办?
您需要像在 take(1)
pipe
运算符中添加 flatMap
试试这个:
this.route.queryParams.pipe(take(1), flatMap(params => {
})
是的,用 mergeMap 替换 flatMap 是一个不错的选择,因为它们是同一件事。在某些时候,flatMap 被重命名为 mergeMap。如果您使用 mergeMap,则无需对代码进行任何更改。