angular6 – Angular 6属性’map’在’Object’类型上不存在
发布时间:2020-12-17 17:52:22 所属栏目:安全 来源:网络整理
导读:我有一个api,返回像这样的对象/数组: (2) [{...},{...}] object 0: {a: '1',b: {id: '1'}} 1: {a: '2',b: {id: '2'}} 所以它看起来像对象的数组(但是debuges说’对象’). 所以在我的代码中我有: return this.http.get(this.url).pipe( map(datas = { retur
我有一个api,返回像这样的对象/数组:
(2) [{...},{...}] object 0: {a: '1',b: {id: '1'}} 1: {a: '2',b: {id: '2'}} 所以它看起来像对象的数组(但是debuges说’对象’). 所以在我的代码中我有: return this.http.get(this.url).pipe( map(datas => { return datas.map(data => { let object = { a: data['a'],b: data['b']['id'],} return object; }) }) ); 但那里: return datas.map(data => { 我收到一个错误: Property 'map' does not exist on type 'Object'. 但应用程序运行良好是正确显示此数据.但这个错误很烦人. 我能做什么? 解决方法
以下运算符在RXJS6中重命名
catch() => catchError() do() => tap() finally() => finalize() switch() => switchAll() 此外,一些Observable创建方法被重命名/重构: throw() => throwError() fromPromise() => from() (this automatically detects the type) FOR MAP语法 import { map } from 'rxjs/operators'; myObservable .pipe(map(data => data * 2)) .subscribe(...); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |