axios使用formdata方式post數據,非文件

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'
        }
      })
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章