代码之家  ›  专栏  ›  技术社区  ›  Davi Resio

我不能以我的服务角度导入地图

  •  -1
  • Davi Resio  · 技术社区  · 7 年前

    我使用的是角度6,我不能导入操作员地图,我尝试两种方式导入:

    使用“rxjs/operators”中的import{map};但是visual studio代码中没有使用此运算符,我给出了以下错误:

    enter image description here

    如果我像这样导入:import'rxjs/add/operator/map';

    我也给错了

    enter image description here

    enter image description here

    如何导入此操作员地图?

    2 回复  |  直到 7 年前
        1
  •  1
  •   Gourishankar    7 年前

    导入方式:-

    import { map } from 'rxjs/operators';
    

    并像这样使用它:

    const example = source.pipe(map(val => val + 10)); Or
    
    getValues(): Observable<Value[]> {   
      return this.http.get<Response<Values>>(this.url).pipe(
        map(reponse => reponse.data.values)
      );
    };
    

    你不见了。烟斗,希望有帮助!

        2
  •  1
  •   Hooter    7 年前

    如果使用Angular6,则使用RXJS6。 对于RxJs 6,您需要使用 map 这样地:

    import { map } from 'rxjs/operators';
    
    return this.http.post('...')
      .pipe(
        map((...) => {...})
      );
    

    阅读更多 https://medium.com/@swapnilkls29/rxjs-6-0-migration-37a6f3de0000 或者这里 https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md

    推荐文章