当输入无效 URL 时,Nuxtjs 在开发模式下超出了最大调用堆栈大小,并且在生产中出现服务器错误 500,而不是我的自定义错误页面
P粉872101673
P粉872101673 2023-09-01 14:33:51
[Vue.js讨论组]

当我输入不存在的 URL 时,有时会收到自定义错误,大多数情况下会收到服务器错误(图片)

这是我的 error.vue 页面:

<template>
  <div class="error-page">
    <div class="page-not-found" v-if="error.statusCode === 404">
      <div class="image">
        <img src="/images/page-not-found.png" alt="page not found">
      </div>
      <h1 class="text-capitalize font-weight-bold">
        {{ $t('notFound.error404') }}
      </h1>
      <p class="info my-3 my-lg-4">
        {{ $t('notFound.error404Info') }}
      </p>
    </div>
    <h1 class="text-capitalize font-weight-bold"  v-else-if="error.statusCode === 500">
      {{ $t('notFound.error500') }}
    </h1>
    <h1 class="text-capitalize font-weight-bold"  v-else>
      {{ $t('notFound.error500') }}
    </h1>
    <NuxtLink class="home-back text-capitalize mb-lg-3" :to="localePath('/')">
    {{ $t('notFound.home') }}
    </NuxtLink>
  </div>

</template>

<script>
export default {
  props: ['error']
}
</script>

<style lang="scss" scoped>
//removed to minimize the code
</style>

注意:1- trrrrr 只是我在 URL 中写入的随机字符串,用于演示不存在的 URL 2-在开发模式下,有时我会收到自定义的 404 错误,大多数时候我会收到 Maximum call stack size returned 错误(图片)

我的 PWA 配置:

pwa: {
    meta: {
      title: "example",
      author: "example",
    },
    icon: { purpose: "any" },
    manifest: {
      display: "standalone",
      name: "example",
      lang: "en",
      useWebmanifestExtension: true,
      theme_color: "#01bac6",
    },
  },

我的问题是:1-为什么我的自定义错误页面始终不起作用?

2- 为什么代码错误 500,而应该是 404,因为我进入了一个不存在的页面?

P粉872101673
P粉872101673

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号