axios.get使用陣列發送 params with arrays
使用params可不用全部欄位都擠在同一行編寫
後續維護編輯相對較好查找
type1. 欄位[0]=陣列[0]
axios.get('/myController/myAction', {
params: { storeIds: [1,2,3] },
paramsSerializer: {
indexes: true, // use brackets with indexes
}
)
結果: /myController/myAction?storeIds[0]=1&storeIds[1]=2&storeIds[2]=3
type2. 欄位=陣列[0]
axios.get('/myController/myAction', {
params: { storeIds: [1,2,3] },
paramsSerializer: {
indexes: null, // no brackets at all
}
)
結果: /myController/myAction?storeIds=1&storeIds=2&storeIds=3
type3. 欄位[]=陣列[0]
axios.get('/myController/myAction', {
params: { storeIds: [1,2,3] },
paramsSerializer: {
indexes: false, // brackets but no indexes
}
)
結果: /myController/myAction?storeIds[]=1&storeIds[]=2&storeIds[]=3