文章:https://www.cnblogs.com/zbx-boke/p/9506370.html
1.打开config/index.js
2.在dev配置对象中找到proxyTable:{}
3.添加如下配置
// 配置反向代理,解决跨域请求
proxyTable: {
'/api': {
target: 'http://www.ajax.cn',
changeOrigin: true,
pathRewrite: {
'^/api': '/api'
}
}
}
4.重启开发服务器npm run dev
网友评论