vue中的http请
来源:互联网 发布:阿里云系统root 编辑:程序博客网 时间:2024/05/24 07:07
如果vue想发送请求,需要引入: vue-resouce
get:
this.$http.get('aa.txt').then(function(res){
alert(res.data);
},function(res){
alert(res.status);
});
给服务发送数据:√
this.$http.get('get.php',{
a:1,
b:2
}).then(function(res){
alert(res.data);
},function(res){
alert(res.status);
});
post:
this.$http.post('post.php',{
a:1,
b:20
},{
emulateJSON:true
}).then(function(res){
alert(res.data);
},function(res){
alert(res.status);
});
jsonp:
this.$http.jsonp('https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su',{
wd:'a'
},{
jsonp:'cb' //callback名字,默认名字就是"callback"
}).then(function(res){
alert(res.data.s);
},function(res){
alert(res.status);
});
get:
this.$http.get('aa.txt').then(function(res){
alert(res.data);
},function(res){
alert(res.status);
});
给服务发送数据:√
this.$http.get('get.php',{
a:1,
b:2
}).then(function(res){
alert(res.data);
},function(res){
alert(res.status);
});
post:
this.$http.post('post.php',{
a:1,
b:20
},{
emulateJSON:true
}).then(function(res){
alert(res.data);
},function(res){
alert(res.status);
});
jsonp:
this.$http.jsonp('https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su',{
wd:'a'
},{
jsonp:'cb' //callback名字,默认名字就是"callback"
}).then(function(res){
alert(res.data.s);
},function(res){
alert(res.status);
});
阅读全文
0 0
- vue中的http请
- vue $http请求服务
- vue.js初识,请多指教。
- vue-resource HTTP API基础
- Vue axios处理http请求
- Vue axios处理http请求
- 请说说HTTP和HTTPS
- vue中的指令
- vue中的渐进过渡
- vue中的初始排序
- Vue开发中的常见问题
- Vue开发中的常见问题
- Vue组件中的slot
- vue中的生命周期
- vue中的webpack
- Vue实例中的生命周期
- vue中的video
- vue路径中的#号
- SEnet (squeeze and excitatiuon)-一种对通道进行加权叠加的操作。
- 变长数组vla(realloc的扩容)
- SpringMVC将参数配置在URL中
- vue+element爬坑
- JAVA String的一些特殊方法
- vue中的http请
- CPUIDFIELD:CPUID字段的统一编号、读取方案。范例:检查SSE4A、AES、PCLMULQDQ指令
- MyBatis 实践中遇到的问题
- 51nod 1007 背包变形
- Python遇到的问题记录!
- Spring官网下载
- 特征工程
- Gitlab
- Unix时间戳转java.util.Date,以及日期函数date_sub()