使用vue框架,搭配vue-resource,代碼貼在下面了,在登陸頁的接口是用的post請求,一切正常,可以傳參并且接收返回值,但是在這一頁用get一直傳不了參數(shù)(php接收到的參數(shù)是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()); //這里在前臺控制臺返回的是接收到的參數(shù),得到的結(jié)果一直為[]
extract($request->all());
$question=Question::find($id);
return ApiHelper::Response(0,'success',$question);
}
歡迎選擇我的課程,讓我們一起見證您的進步~~
vue GET傳遞參數(shù)要加上params
this.$http.get('/operation/customer/question/edits',{params:{id: 10}})
另外說一句,現(xiàn)在VUE官方推薦使用axios vue-resource不更新了