Angular 2 HTTP客户端奇怪的行为

时间:2016-07-30 17:06:40

标签: http angular get angular2-services

所以目前我正在尝试使用angular2应用程序但我在使用http.get(url)时遇到了奇怪的反应。

let url = http://localhost/site/get/data?id='+id;
return this._http.get(url).map(
      res => res.json()

问题是当我使用localhost进行测试时,它适用于我的笔记本电脑,但是当我将其切换到我的ip(192.168.1.xx)时。

let url = http://192.168.1.xx/site/get/data?id='+id;
return this._http.get(url).map(
      res => res.json()

它停止给我结果,并在我的代码中给我空列表响应。

但奇怪的是,如果我在其他具有192.168.1.xx IP的设备上使用它,它在我的电脑上无法在本地工作,它会给我正确的结果。

我甚至手动尝试在我的浏览器本地和邮递员上使用get语句,两者都给我正确的结果。

任何人都知道为什么地址切换会发生这个问题?

0 个答案:

没有答案
相关问题