您需要序列化您的参数,并且您可以通过编写此 github 问题中提到的小配置来完成,
通常你会在 main.js 文件或应用程序的顶级文件中有这个配置,但这同样取决于你想要执行它的时间
// main.js
import axios from "axios";
// Format nested params correctly
axios.interceptors.request.use(config => {
window.console.log(config);
config.paramsSerializer = params => {
// Qs is already included in the Axios package
return Qs.stringify(params, {
arrayFormat: "brackets",
encode: false
});
};
return config;
});
从 axios 0.18.0 开始:
// main.js
import axios from "axios";
import Qs from 'qs';
// Format nested params correctly
axios.interceptors.request.use(config => {
config.paramsSerializer = params => {
// Qs is not included in the Axios package
return Qs.stringify(params, {
arrayFormat: "brackets",
encode: false
});
};
return config;
});