vue项目404报错页面

你访问的页面不存在,3秒后跳转到首页(vue)

只做为一个记载,方便以后查看

<template>
  <div class="err">
    <div class="message">
      你访问的页面不存在, <span>{{ count }}</span
      >秒后将自动返回登录页......
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      count: '',
    }
  },
  created() {
    this.go2home()
  },
  methods: {
    //3秒后返回首页
    go2home() {
      const time_count = 3
      if (!this.timer) {
        this.count = time_count
        this.timer = setInterval(() => {
          if (this.count > 0 && this.count <= time_count) {
            this.count--
          } else {
            clearInterval(this.timer)
            this.timer = null
            //跳转到首页
            this.$router.push('/')
          }
        }, 1000)
      }
    },
  },
}
</script>

<style lang="less" scoped>
.err {
  position: fixed;
  width: 100%;
  height: 100%;
  background: url('https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2245376641,583831489&fm=26&gp=0.jpg') no-repeat center;
  background-size: cover;
  .message {
    color: blue;
    text-align: center;
    margin-top: 20px;
  }
}
</style>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值