search

Home  >  Q&A  >  body text

php - vue-resource's get request cannot send parameters

Using the vue framework, paired with vue-resource, the code is posted below. The interface on the landing page uses post requests. Everything is normal. You can pass parameters and receive return values, but on this page, you cannot use get to pass them. Parameters (the parameters received by php are null), please help....

js part:

this.$http.get('/operation/customer/question/edits',{id: 10}).then(response => {
    this.question = response.body.data;
},response => {
    this.error('连接错误');
})

php part:

public function edits(Request $request){
    dd($request->all());  //这里在前台控制台返回的是接收到的参数,得到的结果一直为[]
    extract($request->all());
    $question=Question::find($id);
    return ApiHelper::Response(0,'success',$question);
}

天蓬老师天蓬老师2739 days ago1003

reply all(2)I'll reply

  • 扔个三星炸死你

    扔个三星炸死你2017-06-29 10:10:18

    Vue GET transfer parameters must be added with params

    this.$http.get('/operation/customer/question/edits',{params:{id: 10}})

    In addition, VUE officially recommends using axios vue-resource and it will not be updated

    reply
    0
  • 阿神

    阿神2017-06-29 10:10:18

    It is recommended to use axios

    reply
    0
  • Cancelreply