从0到1完成一个Vue后台管理项目(六、404页)

本文介绍了如何在Vue后台管理项目中创建404错误页面,包括在components目录下新建404.vue组件,设置router-link进行跳转,以及配置相应的路由。同时,文章提到了404页面的样式调整,包括添加动画效果和响应式设计。
摘要由CSDN通过智能技术生成

往期

从0到1完成一个Vue后台管理项目(一、创建项目)

从0到1完成一个Vue后台管理项目(二、使用element-ui)

从0到1完成一个Vue后台管理项目(三、使用SCSS/LESS,安装图标库)

从0到1完成一个Vue后台管理项目(四、引入axios、配置路由)

从0到1完成一个Vue后台管理项目(五、登录页(表单校验的使用和封装))

从0到1完成一个Vue后台管理项目(五、登录页,mock,token,axios封装)

书写404

我们访问到没有的路径的时候,是需要去设置一个404页面的

在components目录下新建404.vue

在这里插入图片描述

这里唯一注意的就是我们要给一个router-link,给一个跳转的链接

然后我们再去设置相对应的路由
在这里插入图片描述

调整404样式

之前的样式太丑了,就找了一个好看的404页
在这里插入图片描述
代码:

<template>
  <div class="container-box">
    <div class="main-container">
      <div class="data">
        <span>Error 404</span>
        <h1 class="title">Hey Buddy</h1>
        <p>We can't seem to find the page <br />you are looking for.</p>
<!--        <a href="javascript:;" class="button"> </a>-->
        <router-link class="button" to="/"> Go Home</router-link>
      </div>

      <div class="ghost-img">
        <img src="../assets/ghost-img.png" alt="" />
        <div class="ghost-shadow"></div>
      </div>
    </div>

    <div class="main-footer">
      <span>shaka</span>
      <span>|</span>
      <span>shakashaka.top</span>
    </div>
  </div>
</template>

<script>
export default {}
</script>

<style lang="scss" scoped>
.container-box {
  //background-color: #9dd3a8;
  background-color: #9dd3a8;
  display: grid;
  padding: 144px 0 32px;
  height: 100vh;
  color: #161513;
  font-size: 15px;
  font-weight: 500;
  box-sizing: border-box;
}

.main-container {
  display: grid;
  align-content: center;
  row-gap: 40px;
  max-width: 992px;
  margin-left: 24px;
  margin-right: 24px;
}
.data {
  text-align: center;
}

.title {
  font-size: 38px;
  margin: 12px 0;
}

.button {
  display: inline-block;
  margin-top: 32px;
  padding: 12px 24px;
  background-color: #161513;
  color: #fff;
  border-radius: 48px;
  transition: 0.4s;
  text-decoration: none;
}

.button:hover {
  box-shadow: 0 4px 12px rgba(34, 24, 6, 0.2);
}

.ghost-img {
  justify-self: center;
}
.ghost-img img {
  width: 230px;
  animation: floaty 1.8s infinite alternate;
}

@keyframes floaty {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(15px);
  }
}

.ghost-shadow {
  width: 130px;
  height: 24px;
  background-color: rgba(60, 52, 38, 0.16);
  border-radius: 50%;
  margin: 0 auto;
  filter: blur(7px);
  animation: shadow 1.8s infinite alternate;
}

@keyframes shadow {
  0% {
    transform: scale(1, 1);
  }
  100% {
    transform: scale(0.85, 0.85);
  }
}

.main-footer {
  align-self: flex-end;
  display: flex;
  justify-content: center;
  font-size: 12px;
  column-gap: 8px;
}

@media screen and (max-width: 320px) {
  .container-box {
    padding-top: 112px;
  }
}

@media screen and (min-width: 992px) {
  .main-container {
    grid-template-columns: repeat(2, 1fr);
    align-items: center;
    column-gap: 32px;
  }

  .data {
    text-align: initial;
  }

  .ghost-img img {
    width: 400px;
  }

  .ghost-shadow {
    width: 250px;
    height: 40px;
  }
}

@media screen and (min-width: 1024px) {
  .main-container {
    margin-left: auto;
    margin-right: auto;
  }

  .container-box {
    font-size: 16px;
  }

  .title {
    font-size: 80px;
  }

  .main-footer {
    font-size: 13px;
  }
}

@media screen and (min-width: 2048px) {
  .container-box {
    zoom: 1.7;
  }

  .main-container {
    column-gap: 64px;
  }
}

@media screen and (min-width: 3840px) {
  .container-box {
    zoom: 3.1;
  }
}
</style>

在这里插入图片描述
图片也给大家放到这里

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林多多@

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值