1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Vue axios调用第三方接口跨域解决

Vue axios调用第三方接口跨域解决

时间:2021-04-10 11:42:16

相关推荐

Vue axios调用第三方接口跨域解决

1.我要调用的接口是http://app.so/api/v5/appso/discount/?platform=web&limit=10

2.在config->index.js文件中设置跨域配置:

proxyTable: {'/api': {//接口target: 'http://app.so',//要访问的源changeOrigin: true //允许跨域}},

3.在组件中发送请求:

this.$http.get("/api/v5/appso/discount/?platform=web&limit=10").then(function(res) {// 连接成功后的回调函数console.log("连接成功");console.log(res);}).catch(function(err) {// 连接失败后的回调函数console.log("连接失败" + err);});

参考:Vue axios调用第三方接口跨域解决

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。