美文网首页
vue配置 proxytable详解

vue配置 proxytable详解

作者: 佐伊zero | 来源:发表于2018-05-22 14:19 被阅读0次

proxyTable: {
'/geoconv': {
target: 'https://api.map.baidu.com', // 你接口的域名
// secure: false,
changeOrigin: true
// pathRewrite: {
// '^/apis': ''
// }
}
},
1.开启代理: changeOrigin 设置为true, 代表开启代理
2.target: 要请求地址的域名,
3, this.$http.get('/geoconv/v1/?coords=' + longitude + ',' + latitude + '&from=1&to=5&ak=你的ak', null, res => {
console.log(res.result)
longitude = res.result[0].x
latitude = res.result[0].y
})
设置请求路径,用 / geoconv匹配
4.原理: 将用本地起的服务器请求目标的服务器,前端页面,请求本地代理服务器

相关文章

网友评论

      本文标题:vue配置 proxytable详解

      本文链接:https://www.haomeiwen.com/subject/anbhjftx.html