-
配置
(1)安装router
npm install vue-router --save
(2)配置跨域代理
proxyTable: {“/api”:{
target:“http://localhost:8080”,//跨域地址
changeOrigin:true,
pathRewrite:{
‘^/api’:’’
}
}},
-
vue前台跨域请求获得数据
this.$http.get(‘http://localhost:8080/aaa/login’).then(response => {
this.contacts = response.data;
_this.tableData = this.contacts//传给el- table
console.log(this.contacts)
}) -
后台servlet所需头配置
resp.setHeader("Access-Control-Allow-Origin", "*");
resp.setHeader("Access-Control-Allow-Methods", "*");
resp.setHeader("Access-Control-Max-Age", "3600");
resp.setHeader("Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept");