1.问题:
    后端给的接口是:http://8.136.158.178 前端在本地开发中调用该接口跨域。
    2.解决方案:
    * 在webpack中配置proxy。如下图所示(dev环境下可以进行代理,跨域请求)。路径:config/index.js
    image.png

    1. proxyTable: {
    2. '/api': {
    3. target: 'http://8.136.158.178', //后期可以改
    4. changeOrigin: true,
    5. pathRewrite: {
    6. '^/api': ''
    7. }
    8. }
    9. },

    如上:
    1. target是你要代理的域名,必须要加上http。
    2. 这里用’/api’代替target里面的地址,组件中调用接口时直接用’/api’代替。
    比如我要调用http://8.136.158.178/news.直接写’/api/news’即可。
    3. changeOrigin必须为true

    build环境下没有成功!!!!!