好的,所以我正在关注 ionic 3 上的遍历媒体教程,当我到达创建提供程序的部分时,我收到错误消息,指出在此处检测到无法访问的代码:
.map((res: Response) => res.json() );
它也在打字稿上说
找不到名称“地图”您的意思是“地图”吗?
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';
@Injectable()
export class WeatherProvider {
apiKey = "89cca14f4ffcd27d602ad5e587f8e17f";
url;
constructor(public http: HttpClient) {
console.log('Hello WeatherProvider Provider');
this.url = "api.openweathermap.org/data/2.5/weather?q=";
}
getWeather(city, country){
return this.http.get(this.url+city+','+country);
.map((res: Response) => res.json() );
}
}
中的 return 语句getWeather()
使.map()
无法访问。您应该使 return 语句成为函数中的最后一条语句。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句