美文网首页
vue + axios +elementui 调用第三方接口

vue + axios +elementui 调用第三方接口

作者: 中规中矩的蒸汽波boy | 来源:发表于2019-04-18 13:37 被阅读0次

此方法适用于

服务器配置: Allow-Control-Allow-Origin: *

客户端配置:['Content-Type'] = 'application/x-www-form-urlencoded';

1:根目录/config/index.js


proxyTable: {

  '/api': {

      target: 'https://api.map.baidu.com',

      changeOrigin: true,

       pathRewrite: {
               '^/api': ''
        }
    }
}

2:引用 - (注意前缀(’/api/‘))


axios.get(`/api/geocoder/v2/callback=?`).then((response)=>{

      var res = response.data;

      console.log(res);

})

相关文章

网友评论

      本文标题:vue + axios +elementui 调用第三方接口

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