不好意思找后端,自己配一下跨域也很方便
上代码
/*
vue.config.js
*/
devServer: {
host: "localhost",
port: 3000,
https: false, //https的接口,本地http也可以访问
open: true,
proxy: {
'/api': {
target: '后端接口文档地址',
changeOrigin: true, //是否开启跨域
pathRewrite: { //将/api的部分替换
'^/api': '/'
}
}
},
overlay: {
warnings: true,
errors: true
}
},
/*
main.js
*/
var baseUrl = "./" //设置为空(系统自动识别),或者本地地址