axios将数据请求格式修改为application/x-www-form-urlencoded

axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'

axios.defaults.transformRequest = [data=> {
  let ret = ''
  for (let it in data) {
    ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
  }
  return ret
}]

猜你喜欢

转载自www.cnblogs.com/wenxiangxu/p/9178898.html
今日推荐