vuejs跨域请求解决方法

xiaoxiao2021-02-28  52

找到config/index.js目录:

proxyTable: { '/api': { target: 'http://172.16.2.245/', //设置调用接口域名和端口号别忘了加http changeOrigin: true, pathRewrite: { '^/api': '/' //这里理解成用‘/api’代替target里面的地址,组件中我们调接口时直接用/api代替 // 比如我要调用'http://0.0:300/user/add',直接写‘/api/user/add’即可 代理后地址栏显示/ } } },
转载请注明原文地址: https://www.6miu.com/read-2632280.html

最新回复(0)