【问题标题】:NuxtLink redirecting to wrong urlNuxtLink 重定向到错误的 url
【发布时间】:2021-07-19 11:00:38
【问题描述】:

我有一个静态生成的 Nuxt 站点。当我 loaclly 托管它时,一切正常,但是当我在 GitHub Pages 中加载它时,NuxtLinks hrefs 不正确。

例如我的一个链接是:

<NuxtLink to="/iot">IoT</NuxtLink>

在 localhost 上,我的站点索引位于 http://localhost:3000 并且我正确地登陆 http://localhost:3000/iot。

在(因为它在回购中)我的网站索引位于https://lorenzofiamingo.com/prisma/,我登陆https://lorenzofiamingo.com/iot而不是https://lorenzofiamingo.com/prisma/iot

如何修改此行为(更正根目录)?

【问题讨论】:

    标签: javascript html vue.js nuxt.js


    【解决方案1】:

    配置router.base设置基础URL:

    // nuxt.config.js
    export default {
      router: {
        base: '/prisma/'
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2020-07-07
      • 2021-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-27
      • 2020-06-22
      • 1970-01-01
      相关资源
      最近更新 更多