03vue-resource

实现 get 、post、jsonp 请求

this.$http.get('url').then(function(result){

​ result.body //返回的数据

});

//手动发起的post请求,没有表单格式(application/x-www-form-urlencoded),有的服务器处理不了

//emulateJSON:true 表示为表单格式

this.$http.post('url', {}, {emulateJSON:true}).then(function(result){

​ result.body //返回的数据

});

this.$http.jsonp('url').then(result=>{

result.body //返回的数据

});

配置全局选项

  • Vue.http.options.root = 'http://....../';

  • 单独发送请求的url中最前面不用带 /

  • Vue.http.options.emulateJSON = true; //全局启用此选项

posted @ 2021-01-18 23:15  微客鸟窝  阅读(2)  评论(0)    收藏  举报
/* 看板娘 */