axios使用formdata方式post数据,非文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_31201781/article/details/87256606
axios({
        method: 'post',
        url: '/djauth/sso/ssoLogin.do',
        data: params,
        // 转换数据的方法
        transformRequest: [
          function (data) {
            let ret = ''
            for (let it in data) {
              ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
            }
            ret = ret.substring(0, ret.length - 1)
            return ret
          }
        ],
        // 设置请求头
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      })

猜你喜欢

转载自blog.csdn.net/qq_31201781/article/details/87256606