您需要序列化参数,并且可以通过编写 此github问题中
提到的小配置来完成,
通常,您可以在应用程序的main.js文件或顶级文件中拥有此配置,但同样取决于您何时执行它
// main.jsimport axios from "axios";// Format nested params correctlyaxios.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", enpre: false }); }; return config;});
从axios 0.18.0开始:
// main.jsimport axios from "axios";import Qs from 'qs';// Format nested params correctlyaxios.interceptors.request.use(config => { config.paramsSerializer = params => { // Qs is not included in the Axios package return Qs.stringify(params, { arrayFormat: "brackets", enpre: false }); }; return config;});
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)