首页 文章

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

提问于
浏览
1
this._weatherService.getWeather(this.location.city,this.location.code).subscribe((response) => {
     console.log(response);
     this.weather = response;
   });

得到此错误“消息”:“属性'订阅'在类型'void'上不存在 . ”

1 回答

  • 0

    你的issuse是因为你没有 getWeather() 来自 getWeather()

    如错误 void 所说(意味着你没有退货)

    SO in getWeather() use return:

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

相关问题