VUE - 配置跨域

'/api': {
        target: 'http://localhost:8088/',  //这里后台的地址模拟的;应该填写你们真实的后台接口
        changOrigin: true,  //允许跨域
        pathRewrite: {
          /* 重写路径,当我们在浏览器中看到请求的地址为:http://localhost:8088/api/hello 时
            实际上访问的地址是:http://localhost:8088/hello,因为重写了 /api
           */
          '^/api': ''
        }

将上面的代码复制到 config目录下的index.js的 proxyTable{} 中

 

posted @ 2021-11-15 22:02  武卡卡  阅读(263)  评论(0编辑  收藏  举报