//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);
});
vue-cli3.x vue.config.js 跨域配置
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.