跨域处理
在vue.config.js中的写如下代码
devServer:{
open:true,//是否自动弹出浏览器页面
host:'8081',//端口号
https:false,//是否使用https协议
hotOnly:false,//是否开启热更新
proxy:{
//关键词
'/api':{
target:'http:localhost:5000',//API服务器的地址
ws:true,//代理websorkets
changeOrigin:true,//虚拟的站点需要更换origin
pathRewrite:{
//重写路径 比如'/api/aaa/bbb'重写为'/aaa/bbb'
'^api':''
}
}
}
}
以上内容希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的。