跨域访问
1.找vue.config.js
文件,没有新建一个
module.exports = {
devServer: {
proxy: {
'/api': {
target: 'http://localhost:8080',//服务器目标端口
// ws: true,
changeOrigin: true,
pathRewrite:{
'^/api':''
}
}
}
}
}
2.在main.js
中添加 axios.baseURLL='/api'
//跨域里加
axios.baseURLL='/api'
3.在接口访问时路径前面加上/api
return axios({
url: `/api/student/findStudentMessage`,
method: "post",
});