Angular 6中zip已经被弃用:不再支持resultSelector,应使用管道到map代替。

7
在Angular 6中,zip已被弃用:
tslint会给我以下提示: zip已弃用:resultSelector不再支持,请改用管道操作符map 如何升级以下代码:
import {interval, from, zip} from 'rxjs';
let testArray = [1, 2, 3, 4, 5];
array$ = from(testArray);
inter$ = interval(1000);
numbersOverTime$ = zip(array$, inter$, (item, i) => item);
1个回答

8

只需使用zipmap即可:

numbersOverTime$ = zip(array$, inter$)
  .pipe(
    map(([item, i]) => item)
  );

5
我似乎仍在收到这个检测错误:zip 已被废弃:不再支持 resultSelector,请改用管道操作 map。 - apollowebdesigns
我在这里展示的内容没有使用 resultSelector 参数,因此错误必须来自于您代码中的其他地方。 - martin
@apollowebdesigns,你能够找出问题所在吗? - Michael Kargl

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接