乐趣区

关于javascript: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;
    }
})
退出移动版