Angular5到Angular6:Property 'map' does not exist on type 'Actions'. Property 'mergeMap' does

报错内容:

Property 'map' does not exist on type 'Actions'.

Property 'mergeMap' does not exist on type 'Actions'.

错误原因:升级到Angular6后,这些方法在写法上做了调整

解决方案:

1.导入方式改变

import {map, mergeMap} from 'rxjs/operators';

2.写法改变

this.myObservable()
    .map(data => {})
    .mergeMap(data => {})

改为=>

this.myObservable()
    .pipe(
        map(data => {}),
        mergeMap(data => {})
    )

 

你可能感兴趣的:(Angular)