常见的跨域:
1、jspn跨域
2、cors跨域(后端开启) 、
3、vue代理服务器proxy跨域
这里以vue脚手架生成的标准项目为准。一般在项目config目录下面有个index文件
解决:
module.exports = {
publicPath: './',
lintOnSave: true,
configureWebpack: {
//关闭 webpack 的性能提示
performance: {
hints:false
}
},
devServer: {
proxy: {
'/api': {
target: 'http:xxxxxxxx',//后端接口地址
changeOrigin: true,//是否允许跨越
pathRewrite: {
'^/api': '/api'
}
}
}
}
}