属性 'subscribe' 中的 angular6 错误在类型 'void' 上不存在

angular6 Error in Property 'subscribe' does not exist on type 'void'

this._weatherService.getWeather(this.location.city,this.location.code).subscribe((response) => {
     console.log(response);
     this.weather = response;
   });

getting this error "message": "Property 'subscribe' does not exist on type 'void'."

你的问题是因为你没有 return 来自 getWeather()

的任何东西

正如错误所述void(意味着你没有return任何东西)

SO 在 getWeather() 中使用 return:

getWeather(..){
...
return whatever_you_have_to_return;
}