在开发环境下 解决跨域问题:找到config/index.js文件
proxyTable: {
'/api': {
target: 'http://127.0.0.1:8080/',//设置你调用的接口域名和端口号 别忘了加http
changeOrigin: true,
pathRewrite: {
'^/api': '/'
//这里理解成用'/api'代替target里面的地址,
//后面组件中我们掉接口时直接用api代替 比如我要调
//用'http://127.0.0.1:8080/login',直接写/api/login'即可
}
}
}
配合webpack实现跨域请求(axios请求)
最新推荐文章于 2025-04-01 07:30:00 发布