axios.post('/api/data', { data: '请求体传递的数据' }) .then(response => { console.log(response); }) .catch(error => { console.log(error); });
axios.post('/api/data', { data: '请求体传递的数据' }, { headers: { 'Content-Type': 'application/json' //或 'application/x-www-form-urlencoded' } }) .then(response => { console.log(response); }) .catch(error => { console.log(error); });