Vue-resource发送请求

var Vue = require('vue');
var VueResource = require('vue-resource');

Vue.use(VueResource);

{
  // GET /someUrl
  this.$http.get('/someUrl').then(result=> {

    // get body data
    this.someData = result.body;

  }, response => {
    // error callback
  });
}

If your web server can't handle requests encoded as application/json, you can enable the emulateJSON option. This will send the request as application/x-www-form-urlencoded MIME type, as if from an normal HTML form.

Vue.http.options.root = '/root';
Note that for the root option to work, the path of the request must be relative. This will use this the root option: Vue.http.get('someUrl') while this will not: Vue.http.get('/someUrl').
全局配置emulateJSON
Vue.http.options.emulateJSON = true;