【问题标题】:Vuepress with base set throws 404 error on refresh带有基集的 Vuepress 在刷新时抛出 404 错误
【发布时间】:2021-09-01 01:52:05
【问题描述】:

我有一个 Vuepress 站点的 index.md。我将 heroImage 设置为 heroImage: /my-image-logo.png

docs/.vuepress/config.js我将标志设置为:

themeConfig: {
    logo: 'my-image-logo.png',
}

它最初可以正常加载,但是,如果我从 index.md 页面导航到 /guide 中的页面,然后刷新页面,则加载失败并出现 404 错误。我假设这是因为我将base 参数设置为:/some/sub/directory/path/,但它似乎找不到它。

是否已经有我没有看到的解决方法?我尝试将基础添加到logo: 参数,但没有任何显示。

我应该提一下,通过使用 withBase 函数,我一直能够渲染的其余图像:

<img :src="$withBase('/aPicture.png')" alt="some picture">

【问题讨论】:

    标签: image http-status-code-404 base vuepress


    【解决方案1】:

    尝试将您的徽标图片放在以下位置:
    docs/src/.vuepress/public/my-image-logo.png

    docs
    └─ src
       ├─ .vueress
       |   ├─ public
       .   |  └─ my-image-logo.png
       .   ├─ config.js
       .   .
    

    然后在config.js 中设置logo 像这样

    themeConfig: {
      ...
      logo: /my-image-logo.png
      ...
    }
    

    当我添加 logo 图片时,此解决方案对我有用

    VuePress 文档

    Asset Handling/Public Files

    【讨论】:

      猜你喜欢
      • 2015-08-02
      • 1970-01-01
      • 1970-01-01
      • 2019-07-02
      • 2013-06-06
      • 1970-01-01
      • 1970-01-01
      • 2021-09-27
      • 1970-01-01
      相关资源
      最近更新 更多