跨域问题
控制台出现问题:“已拦截跨源请求:同源策略禁止读取位于 http://localhost:8811/user/findall 的远....”
方法一:
在index.html中添加
<meta http-equiv="Access-Control-Allow-Origin" content="*" />
后台对应的类中添加:
@CrossOrigin 表示允许跨站请求
方法二:vue中设置代理
创建 vue.config.js
let proxyObj={}
proxyObj['/'] = {
//websocket
ws: false,
//目标地址
target: 'http:localhost:8811',
//发送请求头host会被设置成target
changeOrigin: true,
pathReWrite: {
'^/': '/'
}
}