php - vue-resource的get请求,发送不了参数
本文介绍了php - vue-resource的get请求,发送不了参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
使用vue框架,搭配vue-resource,代码贴在下面了,在登陆页的接口是用的post请求,一切正常,可以传参并且接收返回值,但是在这一页用get一直传不了参数(php接收到的参数是null),求救....
js部分:
this.$http.get('/operation/customer/question/edits',{id: 10}).then(response => {
this.question = response.body.data;
},response => {
this.error('连接错误');
})
php部分:
public function edits(Request $request){
dd($request->all()); //这里在前台控制台返回的是接收到的参数,得到的结果一直为[]
extract($request->all());
$question=Question::find($id);
return ApiHelper::Response(0,'success',$question);
}
解决方案
vue GET传递参数要加上params
this.$http.get('/operation/customer/question/edits',{params:{id: 10}})
另外说一句,现在VUE官方推荐使用axios vue-resource不更新了
这篇关于php - vue-resource的get请求,发送不了参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文