vue后台接收不到get参数怎么回事?

this.$route.query.item是有数据的 哪里也没写错啊 就是收不到数据

mounted () {
 axios.get('http://localhost/douyin_laravel/public/index.php/api/folder').then((res) => {
      this.list = res.data
    })
}
public function file (Request $request) {
        $input=$request->input('name');
}
回复
阅读 4.1k
3 个回答

···

this.$route.query.item

这是前端路由里的参数,后端请求自然是收不到的,你应该把这个参数拼接到后端请求里。
比如
axios.get('http://localhost/douyin_larav...'+this.$route.query.item).then(xxx)

调试要看实际发的网络请求包

F12 -> network查看发送请求的头部与body 是否与后端监听获取一致。

this.$route.query.item 是前端路由的search参数
和后端接受数据没有关系的

http://localhost/douyin_laravel/public/index.php/api/folder这是后端路由,并没有给参数呀

axios.get('http://localhost/douyin_laravel/public/index.php/api/folder',{
    params: { id: 100 }
  }).then((res) => {
      this.list = res.data
    })

这是带参数的

推荐问题
宣传栏