const _ajax = axios.create({
baseURL: baseURL,
headers: {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'},
withCredentials: withCredentials,
// 参数序列化
paramsSerializer: function(params) {
return qs.stringify(params, {arrayFormat: 'repeat'})
}
})
上面写的参数序列化不可以吗? 下面这种拦截却可以
_ajax.interceptors.request.use(function(config) {
config.data = qs.stringify(config.data, {arrayFormat: 'repeat'});
console.log(cofig.data)
return config
})