账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    vue-router在history模式下如何调用api?
    30
    0

    想要访问http://localhost:8080/change/detail/123时调用http://localhost:5438/api/change?id=123获取数据,目前配置如下:

    assetsPublicPath: '/',
    proxyTable: {
          '/api': {
            target: 'http://127.0.0.1:5438/api/',
            changeOrigin: true,
            pathRewrite: {
              '^/api': ''
            }
          }
        },

    路由配置如下

    {
          path: '/change/detail/:id',
          name: 'ChangeDetail',
          component: ChangeDetail
    }

    ChangeDetail中代码如下

    this.$axios.get('api/change?id=' + id)
              .then(response => {
                ......
              })

    但是访问后发现axios请求的url是http://localhost:8080/change/detail/api/change?id=123 而非http://localhost:8080/api/change?id=123
    请问该如何配置呢?谢谢!

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 时间枯萎 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部