想要使用:rxjs 对流里面的元素进行操作(找出偶数,并且乘以2),为何不生效呢?-灵析社区

Frank的私人司机

想要使用:rxjs 对流里面的元素进行操作(找出偶数,并且乘以2) import { of } from 'rxjs'; import { map, filter } from 'rxjs/operators'; const e = of([1,2,3,4,5]) e.pipe( filter(item => item % 2 === 0), map(num => num * 2) ).subscribe(v => console.log(v)) 但是打印的时候并没有任何数据,请问是代码写的有误吗?

阅读量:240

点赞量:17

问AI
超好看鸭
可以看看 AI 的参考答案,把 "of" 改为 "from"