Vue post get请求简易示例
post请求
1 post(){
2 this.$http.post(url,{ //从此处插入请求参数
name:this.name,
password:this.password
}).then(function (res) { 4 //响应成功后执行 6 }, function () { 7 //响应错误回调 8 }) 9 10 }
参数也可用FormData或者 JSON.stringify()格式化后插入
get请求
1 nextOne2 (){ 2 this.$http.get(url,{ 3 params: { 4 filename:this.filename, //或使用url拼接形式,具体根据api参数要求选择 5 userid: this.userid 6 }, 7 } 8 ).then(function(res){ 9 //响应成功后执行 10 }).then(function(res){ 11 // 响应错误回调 12 }) 13 }
posted on 2018-11-22 17:01 handsonalex 阅读(397) 评论(0) 编辑 收藏 举报