设置基准路径
在vue项目中 找到App.vue
在里边引入axios
axios.defaluts.baseURL= "http://localhost:8080"
设置跨域
在后端服务中找到 index.js 将下列代码复制过去
app.use(function(req,res,next){
res.header('Access-Control-Allow-Origin','*');
res.header('Access-Control-Allow-Headers','Content-Type,Content-Length,Authorization,Accept,X-Requested-With,yourHeaderFeild');
res.header('Access-Control-Allow-Methods','PUT,POST,GET,DELETE,OPTIONS');
// 千万不要网%%¥¥¥###
// 千万不要网
// 千万不要网
next();
}