nuxt3框架实现404错误页面配置及代码详解

错误页面可以说是所有网站中都不可缺少页面,因此对于错误页面的处理也就成为所有网站中必要的操作。

本篇文章就来介绍在nuxt3框架中如何配置错误页面,流程如下:


1、跟目录下创建error.vue,到这一步就完成了对错误页面的设置。

看到这里是不是觉得有些不可思议,相对于nuxt2。在nuxt3中对于错误页面的设置不要太简单了。

<template>
<div class="wrap">
<div class="logo">
<h1>404</h1>
<p>The Page not Found-找不到你要访问的页面</p>
<div class="sub">
<p><a href="/">Back</a></p>
</div>
</div>
</div>
</template>
<style scoped>
body {
background: #f3f3e1;
}
.wrap {
margin: 0 auto;
width: 1000px;
}
.logo {
margin-top: 50px;
}
.logo h1 {
font-size: 200px;
color: #8F8E8C;
text-align: center;
margin-bottom: 1px;
text-shadow: 1px 1px 6px #fff;
}
.logo p {
color: rgb(228, 146, 162);
font-size: 20px;
margin-top: 1px;
text-align: center;
}
.logo p span {
color: lightgreen;
}
.sub a {
color: white;
background: #8F8E8C;
text-decoration: none;
padding: 7px 120px;
font-size: 13px;
font-family: arial, serif;
font-weight: bold;
-webkit-border-radius: 3em;
-moz-border-radius: .1em;
-border-radius: .1em;
}
</style>


如图,便是上述错误页面的基础美化。也可以根据有自己的需求美化错误页面。

六月初字帖坊小程序 你想要的字帖模板及工具,这里都有!