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