【发布时间】:2018-11-13 20:36:55
【问题描述】:
好的,所以我正在关注 ionic 3 的 traversy 媒体教程,当我到达创建提供程序的部分时,我得到一个错误,提示在此处检测到无法访问的代码:
.map((res: Response) => res.json() );
它也写在 typescript
找不到名称“地图”,您的意思是“地图”吗?
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 this.http.get(this.url+city+','+country);` - I' m 假设
.map(...)应该紧随其后
标签: javascript typescript ionic-framework visual-studio-code