axios跨域問題
問題描述:
- 在使用vue+axios開發進行post請求,然后出現以下圖片中的跨域問題;

解決方法:
在網上看了一些相關資料,最后找到了解決方法
module.exports = {
dev: {
//...
proxyTable: {
'/api': {
port: 3000,
target: 'http://127.0.0.1:8081/',
chunkOrigins: true,
pathRewrite: {
'^api': ''
}
}
}
}
- 修改config目錄下的index.js檔案中的proxyTable
- chunkOrigins為是否開啟跨域
axios.request({
url: '/api/sysUser/selectUserInfo',
method: 'POST'
}).then(res => {
console.log(res);
}).catch(res => {
console.log('error' + res);
})
在vue組件方法中修改axios
重新啟動專案再次發送post請求,程式正常

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/126523.html
標籤:AI
上一篇:android 高德地圖畫多邊形,已知中心點 寬高畫矩形 ,實際距離 千米轉地圖坐標距離
下一篇:關于MFC檔案傳輸的問題
