如何在数组中正确使用axios参数 [英] How to correctly use axios params with arrays

查看:68
本文介绍了如何在数组中正确使用axios参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在查询字符串中向数组添加索引?

How to add indexes to array in query string?

我尝试过这样发送数据:

I tried send data like this:

axios.get('/myController/myAction', { params: { storeIds: [1,2,3] })

我得到了这个网址:

http://localhost/api/myController/myAction?storeIds[]=1&storeIds[]=2&storeIds[]=3

所以,我应该获得这个网址:

So, I should to get this url:

http://localhost/api/myController/myAction?storeIds[0]=1&storeIds[1]=2&storeIds[2]=3

我应该在我的params选项中添加什么以获取此URL?

What I should add in my params options to get this url?

推荐答案

您可以使用 paramsSerializer 并使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆