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调用第三方接口跨域解决