VUE项目的 config文件夹下index.js文件中修改 dev: proxyTable中的内容(默认是没有内容的):

添加内容:

'/list': {
            target: 'http://xxxxxxxxxxx',
            changeOrigin:true,
            pathRewrite: {
                '^/list': '/'
            }
        }

 

VUE在开发环境下实现跨域

 

2. 请求方式

用axios方式:

VUE在开发环境下实现跨域

前缀list就是1中所设置的。

3.只是开发环境下可以实现跨域,上线项目按照这个配置是不能实现跨域的

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
猜你喜欢
  • 2022-12-23
  • 2021-05-05
  • 2022-12-23
  • 2021-06-17
  • 2021-03-29
  • 2022-12-23
  • 2021-10-11
相关资源
相似解决方案