vue-cli3.x vue.config.js 跨域配置



devServer: { open:
true, //瀏覽器自動打開頁面 host: "0.0.0.0", //如果是真機測試,就使用這個IP port: 8911, https: false, hotOnly: false, //熱更新(webpack已實現了,這里false即可) proxy: { //配置跨域 '/api': { target: "http://139.224.234.237:3000/api", ws:true, changOrigin:true, pathRewrite:{ '^/api':'/' } } } }
//調用
this
.$http.get('/api/order/getOrder') .then(res => { console.log(res.data); }) .catch(err => { console.log(err.data.message); });

參考:

https://blog.csdn.net/weixin_43067157/article/details/82079792?utm_source=blogxgwz0


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM