好的,接下来是关于离子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() );
}
}发布于 2018-11-13 21:13:15
getWeather()中的返回语句使.map()无法访问。您应该将return语句作为函数中的最后一个语句。
https://stackoverflow.com/questions/53289111
复制相似问题