【发布时间】:2018-09-03 19:21:59
【问题描述】:
这就是我的功能,非常简单:
mounted: function(){
this.$http.get('http://localhost:80/gaming/api/game/1').then((data)=>{
console.log(data.body);
});
}
我的 VueJS 应用程序在端口 8080 上运行,我的 PHP 在端口 80 上的 XAMPP 上运行。
当我尝试从我的 API 中获取某些内容时,我收到以下错误:
Uncaught (in promise) Response {url: "http://localhost:80/gaming/api/game/1", ok: false, status: 0, statusText: "", headers: Headers, …}
我能做什么?
【问题讨论】:
-
在浏览器的开发者工具中查看requests(network),可能是preflight requests有问题
-
@Evhz 我检查了网络选项卡,请求似乎出现在那里,并且响应正确。但是承诺在 VueJS 中失败了。
标签: vue.js xampp vuejs2 localhost vue-resource