Vue中如何实现proxy代理

大屋电子 18 0 PDF 2020-12-13 07:12:16

Vue 框架开发的时候,会遇到跨域的问题,可在config/index.js 里配置proxyTable内容,使用proxy 代理。 // config/index.js 文件 proxyTable: { '/api': { target: 'http://192.168.149.90:8080/', // 设置你调用的接口域名和端口号 changeOrigin: true, // 跨域 pathRewrite: { '^/api': '/' } } }, 这里理解成用‘/api’代替target里面的地址,后面组件中我们掉接口

用户评论
请输入评论内容
评分:
暂无评论