问题:
// 发送数据:
request(url, { params: { select: [1,2,3] } })
解决办法:
// 正常版
import request from '../utils/request';
import { stringify } from 'qs';
export const queryList = async (params) => {
request(url, {
params: { select: [1,2,3] },
paramsSerializer: (params) => stringify(params, { arrayFormat: 'brackets' })
})
}
// 更简单点的写法
import request from '../utils/request';
import { stringify } from 'qs';
export const queryList = async (params) => {
return request(`/api/list?${stringify(params, { arrayFormat: 'brackets' })}`);
}