Home > Article > Backend Development > Please tell me, the ajax request sent by vue-resource is always nill.
Excuse me, dear masters,
When I use vue-resource to make ajax requests, the response is always null, but JQuery can respond normally when making requests. Please tell me what is going on,
<code>created:function () { var vm = this; $.get('/a', function (data) { vm.list = data; }); //JQuery请求 this.$http.get('/a', function (data) { vm.list = data; }); //Vue-resource请求 },</code>
Excuse me, dear masters,
When I use vue-resource to make ajax requests, the response is always null, but JQuery can respond normally when making requests. Please tell me what is going on,
<code>created:function () { var vm = this; $.get('/a', function (data) { vm.list = data; }); //JQuery请求 this.$http.get('/a', function (data) { vm.list = data; }); //Vue-resource请求 },</code>
Vue.http.options.emulateJSON = true
@阿发 Thanks, but adding this sentence has no effect,
Just checked it, it received Response { url="/a", ok=true, status=200, more... }
Such an object.
I use this form and can access it normally
<code>`this.$http.get('/a').then(({data})=>{ vm.list = data; console.log(data); },(data)=>{ console.log(data); })`</code>