nuxt3设置404页面

发布时间 2023-11-21 15:28:47作者: 明明一颗大白菜

1.在你的page目录下新建一个[...slug].vue的文件,文件内容为自定为自定义的404内容

<!--404页面-->
<template>
  <div class="error-page">
     404
  </div>
</template>

<script setup lang="ts">

setResponseStatus(404)
</script>

<style scoped lang="less">

</style>

  

2. 部署:

如果你的ssr是关闭的,则不用管,如果是开启状态,需要在你的nginx进行配置一下

server {
    listen  80;
    index index.html;
    root  /www/***/dist/;
    # 主要是这行配置404页面
    error_page 404  /404.html;
     location / {
         index index.html;
     
       }
  
      
}