【问题标题】:How to load a static HTML page in Nuxt (avoiding Nuxt requests)如何在 Nuxt 中加载静态 HTML 页面(避免 Nuxt 请求)
【发布时间】:2019-10-10 02:07:53
【问题描述】:

我有一个具有unsupported page 的 nuxt 网站。当我只想显示一个没有外部请求的静态页面时,我注意到 Nuxt 正在加载它的文件,因为它是一个简单的页面,没有理由加载所有这些文件。

所以问题是:如何在访问 Nuxt 特定路由时提供静态 HTML 文件,例如:/unsupported

现在我正在为页面提供空布局:

<template>
  <div class="unsupported">
    <div class="container">
      <i class="unsupported-icon fa fa-frown-o" />

      <h1>Seu navegador não é suportado</h1>
      <h2>Para usar o Cinemax, nós recomendamos que use a versão mais recente do <a href="#">Firefox</a>, <a href="#">Chrome</a> ou <a href="#">Safari</a></h2>
    </div>
  </div>
</template>

<script>
export default {
  layout: 'empty'
}
</script>

<style lang="scss">
.unsupported {
  display        : flex;
  flex-direction : column;
  justify-content: center;
  align-items    : center;

  &-icon {
    font-size: 4rem;
  }
}
</style>

但我需要它只是一个普通的 HTML 页面。

【问题讨论】:

    标签: nuxt.js static-html


    【解决方案1】:

    抱歉,我不太注意文档中说如果您想提供静态文件,只需将它们放入 /static 项目文件夹的部分。 在我的情况下/static/unsupported.html 然后像这样访问它http://localhost:8000/unsupported.html

    【讨论】:

      猜你喜欢
      • 2022-01-17
      • 1970-01-01
      • 2020-07-29
      • 2019-04-14
      • 2021-04-01
      • 2021-02-28
      • 1970-01-01
      • 2020-07-15
      相关资源
      最近更新 更多