VUE 404页面的实现

article/2025/9/16 17:54:09

效果图:

 实现方式:

创建一个404的vue页面

<template><div class="wscn-http404-container"><div class="wscn-http404"><div class="pic-404"><imgclass="pic-404__parent"src="@/assets/error_img/404.png"alt="404"/><imgclass="pic-404__child left"src="@/assets/error_img/404_cloud.png"alt="404"/><imgclass="pic-404__child mid"src="@/assets/error_img/404_cloud.png"alt="404"/><imgclass="pic-404__child right"src="@/assets/error_img/404_cloud.png"alt="404"/></div><div class="bullshit"><div class="bullshit__oops"><!-- 404错误! -->{{ $t("globalLang.Error404.M000001") }}</div><div class="bullshit__headline"><!-- 找不到网页! -->{{ $t("globalLang.Error404.M000002") }}</div><div class="bullshit__info"><!-- 对不起,您正在寻找的页面不存在。尝试检查URL的错误,然后按浏览器上的刷新按钮或尝试在我们的应用程序中找到其他内容。 -->{{ $t("globalLang.Error404.M000003") }}</div><!-- <router-link to="/" class="bullshit__return-home"> --><!-- 返回首页 --><!-- {{ $t("globalLang.Error404.M000004") }} --><!-- </router-link> --></div></div></div>
</template><script>
export default {name: "Page404",
};
</script><style lang="less" scoped>
.wscn-http404-container {transform: translate(-50%, -50%);position: absolute;top: 40%;left: 50%;overflow: hidden;width: 95%;
}
.wscn-http404 {position: relative;width: 100%;padding: 0 50px;overflow: hidden;.pic-404 {position: relative;float: left;width: 600px;overflow: hidden;&__parent {width: 100%;}&__child {position: absolute;&.left {width: 80px;top: 17px;left: 220px;opacity: 0;animation-name: cloudLeft;animation-duration: 2s;animation-timing-function: linear;animation-fill-mode: forwards;animation-delay: 1s;}&.mid {width: 46px;top: 10px;left: 420px;opacity: 0;animation-name: cloudMid;animation-duration: 2s;animation-timing-function: linear;animation-fill-mode: forwards;animation-delay: 1.2s;}&.right {width: 62px;top: 100px;left: 500px;opacity: 0;animation-name: cloudRight;animation-duration: 2s;animation-timing-function: linear;animation-fill-mode: forwards;animation-delay: 1s;}@keyframes cloudLeft {0% {top: 17px;left: 220px;opacity: 0;}20% {top: 33px;left: 188px;opacity: 1;}80% {top: 81px;left: 92px;opacity: 1;}100% {top: 97px;left: 60px;opacity: 0;}}@keyframes cloudMid {0% {top: 10px;left: 420px;opacity: 0;}20% {top: 40px;left: 360px;opacity: 1;}70% {top: 130px;left: 180px;opacity: 1;}100% {top: 160px;left: 120px;opacity: 0;}}@keyframes cloudRight {0% {top: 100px;left: 500px;opacity: 0;}20% {top: 120px;left: 460px;opacity: 1;}80% {top: 180px;left: 340px;opacity: 1;}100% {top: 200px;left: 300px;opacity: 0;}}}}.bullshit {position: relative;float: left;width: 300px;padding: 30px 0;overflow: hidden;&__oops {font-size: 32px;font-weight: bold;line-height: 40px;color: #1482f0;opacity: 0;margin-bottom: 20px;animation-name: slideUp;animation-duration: 0.5s;animation-fill-mode: forwards;}&__headline {font-size: 20px;line-height: 24px;color: #222;font-weight: bold;opacity: 0;margin-bottom: 10px;animation-name: slideUp;animation-duration: 0.5s;animation-delay: 0.1s;animation-fill-mode: forwards;}&__info {font-size: 13px;line-height: 21px;color: grey;opacity: 0;margin-bottom: 30px;animation-name: slideUp;animation-duration: 0.5s;animation-delay: 0.2s;animation-fill-mode: forwards;}&__return-home {display: block;float: left;width: 110px;height: 36px;background: #1482f0;border-radius: 100px;text-align: center;color: #ffffff;opacity: 0;font-size: 14px;line-height: 36px;cursor: pointer;animation-name: slideUp;animation-duration: 0.5s;animation-delay: 0.3s;animation-fill-mode: forwards;}@keyframes slideUp {0% {transform: translateY(60px);opacity: 0;}100% {transform: translateY(0);opacity: 1;}}}
}
</style>

给加到首页路由里面

 在路由最后面注册一个找不到后就跳转去404

 最后加一个去掉重复路由访问报错的逻辑

// 防止连续点击多次路由报错
let routerPush = Router.prototype.push;
Router.prototype.push = function push(location) {return routerPush.call(this, location).catch(err => err)
}

 


http://chatgpt.dhexx.cn/article/IXood8eB.shtml

相关文章

Django配置404页面

目录 一.settings配置二.url设置三.views中设置四.最后附一个404页面的模板。 一.settings配置 1.首先需要在settings中将DEBUG由原来的True改为False DEBUG False2.需要设置 ALLOWED_OSTS ["*"]二.url设置 三.views中设置 def page_not_found(request,**kwarg…

收集的几个自定义的404页面的模板

文章目录 404pages : HTTP Status 404 – Not Found介绍&#xff1a;404页面分类&#xff1a;补充内容&#xff1a;致谢&#xff1a;声明 404pages : HTTP Status 404 – Not Found 介绍&#xff1a; 注&#xff1a;项目已上传到github&#xff1a;https://github.com/yanshen…

网站怎么自定义404页面

404页面是客户端在浏览网页时&#xff0c;服务器无法正常提供信息&#xff0c;或是服务器无法回应&#xff0c;且不知道原因所返回的页面&#xff0c;简单的说就是当别人访问你网站的某一个已经删除或不存在的网页的时候&#xff0c;服务器自动显示的页面。404页面对seo是有一定…

vue 中编写404页面

前言 今日给自己项目添加404页面时&#xff0c;踩了一点坑&#xff0c;分享给大家。 正文 <div class"_404"><h2 class"m-0">抱歉&#xff0c;页面未找到&#xff0c;<span>{{countDown}}</span>s后自动跳转到<a href"j…

hexo自定义404页面

1.找到你中意的404页面 推荐一款&#xff1a;https://404.life 预览保存&#xff0c;如果你看到其他喜欢的页面如何F12扒页面我就不教咯~ 2.hexo配置 2.1 把css和js放在博客下 我是放在这儿的&#xff0c;你也可以放在github&#xff0c;用jsd加速。 2.2 新建404.html 路…

缤纷多彩的404页面(404.html)

文章来源&#xff1a;https://www.skyqian.com/archives/404-Pages.html 一般而言&#xff0c;第一时间会在博客更新&#xff0c;CSDN随缘更新。 引言 别离滋味浓于酒。著人瘦。此情不及墙东柳。春色年年如旧。 ——勿埋我心 404是个很常见的页面&#xff0c;当该网站的内容搬迁…

html404页面怎么添加,网站要如何设置自定义404页面?

之前我们讲述过网站设置404页面对于优化或是用户体验的重要意义&#xff0c;大家可移步到《网站为什么要设置404页面》查看&#xff0c;今天我们讲解的是网站要如何设置自己的404页面。 现在大多数空间商都有了404设置的功能&#xff0c;我们可将404页面上传至空间里面&#xf…

phpstudy 404页面设置 也就是Apache404页面的设置

1&#xff0c;让apache支持.htaccess 我们要找到apache安装目录下的httpd.conf文件,在里面找到 <Directory /> Options FollowSymLinks AllowOverride none </Directory> 我们只要把蓝色字的none改all就重起apache就好了 如图&#xff1a; 2、找到httpd.conf文件…

个性404页面模板php,25个创意404页面,支持模板下载

对于SEOer来讲,一个好的404页面是很有必要的,既要让蜘蛛能识别出不需要的网页,也要让用户在访问到错误页面时感觉舒服,所以,在选择404页面时SEOer就纠结了,到底什么样的一款404页面是好的呢?或者说是合适的呢? 今天Kane就在这里整理了26款404页面,分别是五个类别,大部…

vue 页面跳转404_出现404页面怎么办?应该如何处理404页面?

当出现404页面怎么办?应该如何处理404页面?我们都知道404页面是用户在输入错误的链接时,显示的返回页面,但是作为SEOer来说,一切与用户有关的事,我们都不能忽略, 当用户已经点击进来,难道要因为出现的404页面而失去众多用户吗?不!这不是一个优秀的SEOer该做的事,下面…

html5 小游戏 404页面,原来404页面可以这样做

404页面是网站必备的一个页面,它承载着用户体验与SEO优化的重任。404页面通常为用户访问了网站上不存在或已删除的页面,服务器返回的404错误。如果站长没有设置404页面,会出现死链接,蜘蛛爬行这类网址时,不利于搜索引擎收录。 设置404页面的两大好处 1:引导用户不要关闭网…

SpringBoot 配置404页面

SpringBoot 配置404页面 项目环境&#xff1a; 服务器&#xff1a;centos 前端&#xff1a;Vue 后端&#xff1a;SpringBoot 出现的问题 访问一个不存在的页面时&#xff0c;会出现tomcat自带的404界面&#xff0c;这个界面对于用户不太友好 解决方案 1、自己写好404页面…

vue 404页面

一、概述 如果用户输入错误的网址没有提示&#xff0c;界面也不会有任何变化&#xff0c;用户体验非常不友好&#xff0c;所以需要设置错误提示 二、设置 设置404页面需要在配置路由文件index.js中设置&#xff0c;其中 * 代表的就是404页面 // 404 page must be placed at the…

自适应404页面

404.CSS *{ padding:0;margin:0;box-sizing:border-box;font-family:"微软雅黑";} body,html{width:100%;height:100%;} .container{max-width:90%;margin:0 auto;padding:80px 0px; } img{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;us…

什么是404页面,404有什么做用,网站做404有什么好处?

什么是404页面&#xff1f; 404页面是客户端在浏览网页时&#xff0c;服务器无法正常提供信息&#xff0c;又不知情况&#xff0c;所返回的页面。很多用户访问错误网页时就会经常出现这个404页面。 所谓404页面主要指的是在运营网站的过程中&#xff0c;当用户点击了某个网页…

网页报错404原因及解决方法

网页报错404&#xff1a;即找不到该资源 未开启服务 若使用的是tomcat服务器&#xff0c;先检查服务器有没有正常启动&#xff0c;网络连接是否正常。 服务器未正确部署 使用开发工具为idea&#xff0c;检查tomcat在idea是否部署正确。 服务器配置出错 tomcat在idea中的配置出错…

404是什么意思,404错误页面有什么用?

在我们浏览网页时&#xff0c;时常会出现一些404页面&#xff0c;导致无法正常浏览网页&#xff0c;那么什么是404呢&#xff0c;为什么会产生404页面呢&#xff1f;下面我们一起来看看。 404介绍 404其实是一种http状态码&#xff0c;代表用户在浏览网页时&#xff0c;服务器…

自制整人电脑小程序

自制整人电脑小程序&#xff0c;有趣的.vbs文件 今天看到一个有意思小程序&#xff0c;可以用来整蛊好朋友&#xff0c;让他们以为电脑收到攻击或者重要文件丢失。制作这个小程序只需要用到电脑最普通的文本文档&#xff0c;只是保存格式不是常用的.txt&#xff0c;而是.vbs。…

删好友警告,C语言最强整人小程序!(勿随便使用)

整人啦!!! 小编一共给你们准备了三个,分别起名为关机、死机、抖动,都给出了代码,大家仅仅用来娱乐,不要乱来哦。。。 注意:如果你用了感到生气的话不要怪小编哦,大家慎用!!! 关机小程序 #include<stdio.h> #include<string.h> #include<stdlib.h&…

C语言丨整蛊必备小程序,好玩炸翻天(附源码)

前言 感觉学了c语言后仍然一无是处&#xff1f;&#xff01;&#xff01;想要整蛊一下朋友仍然不会&#xff1f;&#xff01;&#xff01; 别慌&#xff0c;看完这篇文章&#xff0c;你就会了。 下面给大家分享两个基础的整蛊小程序 1.我是猪关机程序 2.无限弹窗程序 一、…