Home > Backend Development > PHP Tutorial > Please tell me, the ajax request sent by vue-resource is always nill.

Please tell me, the ajax request sent by vue-resource is always nill.

WBOY
Release: 2016-10-10 11:56:08
Original
1322 people have browsed it

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>
Copy after login
Copy after login

Please tell me, the ajax request sent by vue-resource is always nill.

Reply content:

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>
Copy after login
Copy after login

Please tell me, the ajax request sent by vue-resource is always nill.

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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template