1

我在使用带有一些 json 数据的 vue-resource 时遇到问题。我在这里遵循示例:https ://github.com/vuejs/vue-resource/blob/master/docs/http.md

我的 vue-resource 调用如下所示:

  ready: function() {    
    this.$http.get('http://section.dynns.com/sections').then(function (response) {
      this.$set('data_list', response.data)
  });
},

在此处查看 jsfiddle:http: //jsfiddle.net/greene48/yb5chmfr/

但是,将 api 调用切换为不同的数据集似乎可行:http: //jsfiddle.net/greene48/92gfwqL3/

那么,也许我尝试使用的 json 有问题?任何帮助,将不胜感激。谢谢

4

1 回答 1

2

http://jsonplaceholder.typicode.com/posts设置 CORS 标头。http://section.dynns.com/sections没有。如果没有 CORS 标头,您对不同域名的请求将受到浏览器的同源策略的约束,并且会失败。

您的其他选项是 JSONP(如果 API 支持它)或通过服务器端脚本代理请求。

于 2016-02-09T20:04:59.893 回答