Today in the HTTP request, there is a problem, the same interface, the result is exactly the same, but jquery Ajax requests, Can be directly result.code fetch to the value, but in Vue-resource must use Result.body.code to get, this let me very is puzzled, result looked for half a day, vue-resource in processing result, will in its outer package a body layer, real packet in B Ody layer. On this basis of the problem, incredibly do not know, in this post out, to himself to mention a wake up, but also to other like me just in the beginning of the novice compatriots to mention a wake up, lest detours. Although Vue spent more than a year, the problem is really the first time, if not this time jquery and Vue together, perhaps not found ...
Vue-resource code is posted below
1 That . $http. Post (2 URL,3 {4"Train": Train,5 },6{Emulatejson:true}7 ). Then (8 //Successful callback9 function(Result) {Ten if(Result.body.code = = 10000){ One A } - } -);
This is the $ajax of jquery.
1 $.ajax (2 {3 Url:url,4DataType: ' JSON ',5Type: ' POST ',6Data: {' Train ': Train},7Successfunction(Result) {8 if(Result.code = = 10000){9 Ten } One } A } -);
To the novice to see, the predecessors have neglected it ...
Finally fell in the pit!!! Vue-resource and jquery are not the same Ajax