如何在 Nuxt 中加载静态 HTML 页面(避免 Nuxt 请求)
How to load a static HTML page in Nuxt (avoiding Nuxt requests)
我有一个带有 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 页面。
抱歉,我没有太注意文档中说如果您想提供静态文件,只需将它们放入 /static
项目文件夹中的部分。
在我的例子中 /static/unsupported.html
然后像这样访问它 http://localhost:8000/unsupported.html
我有一个带有 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 页面。
抱歉,我没有太注意文档中说如果您想提供静态文件,只需将它们放入 /static
项目文件夹中的部分。
在我的例子中 /static/unsupported.html
然后像这样访问它 http://localhost:8000/unsupported.html