如报错如图所示的错误:
出现这种问题只是跨域时同源策略的问题
解决方案
只需要在根目录下创建一个vue.config.js的文件
文件中写入:
module.exports = {
lintOnSave: false,
devServer: {
host: "localhost",
port: 8080, // 端口号
https: false, // https:{type:Boolean}
open: true, //配置自动启动浏览器
proxy: {
'/admin': { //代理api
target: 'http://ceshi5.dishait.cn/admin',//服务器api地址
ws: true,// proxy websockets
changeOrigin: true,//是否跨域
pathRewrite: { //重写路径
'^/admin': ''
}
}
}
}
}
注意:编写完文件之后一定要重启项目 不然有可能加载不过来