javascript - 使用 Nuxt 生成的自定义 404 页面仅在开发模式下工作
问题描述
我在文件夹中有一个error.vue
页面。layouts
当我在开发模式下访问整个 localhost 的站点时,如果我到达一个名称错误的页面,则会显示 404 页面,但是当我处于生产状态时,我看不到该页面。相反,会出现另一个页面:
这是代码:
<template>
<v-app>
<v-container>
<v-layout row wrap align-center justify-center fill-height>
<v-flex xs12 sm12 md6>
<v-img
:src="require('@/assets/images/404.svg')"
width="90%"
></v-img>
</v-flex>
<v-flex xs12 sm12 md6 class="mb-5">
<h1 class="display-4 light-grey font-weight-medium text-xs-center text-sm-center text-md-left mb-3">Oops!</h1>
<h1 class="display-3 light-grey font-weight-medium text-xs-center text-sm-center text-md-left">The page you are looking for is not found.</h1>
</v-flex>
</v-layout>
</v-container>
</v-app>
</template>
<script>
export default {
props: ['error'],
data() {
return {
}
}
}
</script>
<style scoped>
.light-grey{
color: #4f4f4f;
}
</style>
Nuxt 版本:2.8.1
按照这个https://nuxtjs.org/guide/views/
我错过了什么吗?
解决方案
你用的是nuxt生成模式吗?在这种情况下,如果找不到请求的页面,您忘记设置静态服务器(看起来像 ISS?)以提供 200.html 后备文件。https://nuxtjs.org/api/configuration-generate#fallback
如果您使用的是 nuxt 通用模式,您的代理服务器会调整为拦截错误并显示自己的页面而不是 nuxt 错误页面。
推荐阅读
- anypoint-studio - 骡 3 进口 | 所选文件夹不包含有效的 Studio 项目(缺少 mule-project.xml 文件)
- css - 我无法加载 .woff
- excel - 数据验证应用于任何允许具有特定文本的值的突出显示的列
- google-bigquery - 如何查询 BigQuery 视图和表的依赖关系?
- swift - 如何快速计算变量值的数量?
- python - 如何在python中确定两个向量是线性相关还是独立的?
- c# - PlayAgain 方法
- java - 使用 lombok 1.18.12 构建的 gradle 6.4 不生成 getter 和 setter
- python - 如何在 Python 3 中使用生成器管道?
- javascript - 如何使用 Redux Saga debounce 但先获取而不是等待 n 毫秒