axios使用form格式data发送post请求

axios({
     url: '/api/xxxx',
    method: 'post',
    data:{
        test:1111
    },
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    transformRequest(data){
        let ret = '';
         for (let it in data) {
            ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
         }
        return ret;
    }
})

你可能感兴趣的:(javascript)