vue使用resource发送ajax请求

来源:互联网 发布:网络游戏服务器编程 编辑:程序博客网 时间:2024/06/11 06:05

不简写

getcode:function(){                 this.$http({                    method:'POST',                    url:'/mobile/edit',                    data:{'a':'123124'},                    headers: {"X-Requested-With": "XMLHttpRequest"},                    }).then(function(response){                            this.posts=response.data;                        },function(error){                               alert('数据插入失败,请稍后重试')                            })            }

简写发送get请求

 this.$http.get('data.php').then(function(response){     this.posts=response.data;})

简写发送post请求

 this.$http.post('data.php').then(function(response){     this.posts=response.data;})
0 0
原创粉丝点击