0
我有一个角度为2的应用程序。从rxjs-5.0.0-beta.12
升级至rxjs-5.1.0
,但现在低于this.http.get(...).map()
显示错误。Observable.map - 提供的参数与调用目标的任何签名不匹配
提供的参数不匹配
import { Http, Headers } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
export class BaseService {
private baseUrl: string = 'http://someserver:8080/somedb';
constructor(public http: Http) {}
doGet(url: string, headers?: Headers): Observable<any> {
if(headers) {
return this.http.get(this.baseUrl+url, {headers: headers}).map(response => {
}, err => {
});
}
}
}
错误只添加.map()
发生时,通话对象的任何签名,确实在释放什么变化?
完整IDE消息:
[ts] Supplied parameters do not match any signature of call target.
Applies a given project function to each value emitted by the source
Observable, and emits the resulting values as an Observable.
<span class="informal">Like Array.prototype.map(),
it passes each source value through a transformation function to get
corresponding output values.</span>
<img src="./img/map.png" width="100%">
Similar to the well known Array.prototype.map function, this operator
applies a projection to each value and emits that projection in the output
Observable.
@example <caption>Map every every click to the clientX position of that click</caption>
var clicks = Rx.Observable.fromEvent(document, 'click');
var positions = clicks.map(ev => ev.clientX);
positions.subscribe(x => console.log(x));
@see {@link mapTo}
@see {@link pluck}
@return {Observable<R>} An Observable that emits the values from the source
Observable transformed by the given project function.
@method map
@owner Observable
(property) Observable<Response>.map: <T, R>() => any
还是同样的错误,我会检查它是否仅仅是IDE错误或实际上是一个编译时错误 – Ivaro18
您可以添加的package.json呢? –
好吧,我的坏,我会接受你的答案,问题原来是我的Visual Studio代码不喜欢它。获取电话确实有效 – Ivaro18