proxyTable 设置的target没有效果?

proxyTable中指定的地址怎么没有被设置为实际请求的路径?

http://localhost:8888/data/ap...
这个位置怎么多加了个 data ???

1.proxyTable
clipboard.png
2.使用

clipboard.png

3.结果

clipboard.png

阅读 7.2k
3 个回答

get 使用的是相对路径,需要在 api 前面加一个 / 表示绝对路径

proxyTable: {
      '/list': {
        target: 'http://api.xxx.cn',
        changeOrigin: true,
        pathRewrite: {
          '^/list': '/'
        }
      }

使用

            this.$http.get('list/url')
            .then(function(data){
                //data
            })

亲测 有效,望采纳

target带子目录会报错,如果需要重写用pathRewrite

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题