首页 > 其他 > 详细

vue 配置跨域访问

时间:2017-08-24 13:18:56      阅读:279      评论:0      收藏:0      [点我收藏+]

主要在config->index.js中配置 
proxyTable: { 
‘/gameapi’: { 
changeOrigin: true, 
// target: ‘http://rap.id.cn/mockjs/20‘, mock地址 
target: ‘http://192.168.1.124‘,服务器地址 
pathRewrite: { 
‘^/gameapi’: ‘/gameapi’ 
}, 
secure:false 


因此,发送请求时候url写为(’/gameapi/gift-applylist’)就能拿到接口数据。 
但是注意配置后需要重新npm run dev才会生效。 
当然如果有两个不同路径也可以配置两个 
proxyTable: { 
‘/gameapi’: { 
changeOrigin: true, 
// target: ‘http://rap.id.cn/mockjs/20‘, 
target: ‘http://192.168.1.124‘, 
pathRewrite: { 
‘^/gameapi’: ‘/gameapi’ 
}, 
secure:false 
}, 
‘/cps’: { 
changeOrigin: true, 
// target: ‘http://rap.idu.cn/mockjs/20‘, 
target: ‘http://192.168.1.124‘, 
pathRewrite: { 
‘^/cps’: ‘/cps’ 
}, 
secure:false 

},

vue 配置跨域访问

原文:http://www.cnblogs.com/jackking/p/7422322.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!