关于网友提出的“ vue-resource的get请求,发送不了参数”问题疑问,本网通过在网上对“ vue-resource的get请求,发送不了参数”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: 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);
}


解决方案1:建议使用 axios
解决方案2:vue GET传递参数要加上params
this.$http.get('/operation/customer/question/edits',{params:{id: 10}})
另外说一句,现在VUE官方推荐使用axios vue-resource不更新了
以上介绍了“ vue-resource的get请求,发送不了参数”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/4378838.html