首页 > 解决方案 > 如何在 Nuxt 中加载静态 HTML 页面(避免 Nuxt 请求)

问题描述

我有一个 nuxt 网站,它有一个unsupported page. 当我只想显示一个没有外部请求的静态页面时,我注意到 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.jsstatic-html

解决方案


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


推荐阅读