首页 > 其他 > 详细

vue 通过 vue-resource 调用 后台接口

时间:2019-06-03 12:25:06      阅读:346      评论:0      收藏:0      [点我收藏+]
import Vue from ‘vue‘
import VueResource from ‘vue-resource‘
Vue.use(VueResource);
function HTTP(){
this.Vue=Vue;
//域名
this.baseurl=function(num){
var strurl="";
switch(num)
{
case 1:{strurl="http://localhost:37377";break;}
case 2:{strurl="http://localhost:37377";break;}
default:{strurl="http://localhost:37377";break;}
}
return strurl;
},
//get 提交
this.Get=function(url,param,type){
return this.Vue.http.get(this.baseurl(type)+url,{params:param});
},
//post 提交
this.Post=function(url,param,type)
{
return this.Vue.http.post(this.baseurl(type)+url,param,{emulateJSON:true});

}

}
var http=new HTTP();
export default http;

vue 通过 vue-resource 调用 后台接口

原文:https://www.cnblogs.com/gfbppy/p/10966524.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!