在vue.config.js中配置
module.exports = {
devServer: {
proxy: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: true,
pathRewrite: {
'/api': ''
}
}
}
},
}
修改完这个文件记得重启你的项目
在使用的时候(这里使用axios举例):
比如要访问的是 http://localhost:3000/interface1
这个接口
this.$axios.get('/api/interface1').then(res->{
console.log(res);
})
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。