赶毕业设计遇到的问题|2

2.Vue页面定时自动跳转到静态的html页面

  这里有两个需求点:

  1. Vue页面跳转到html页面
  2. 定时跳转

解决方案:

写一个定时器,当倒计时5秒钟后,自动跳转到指定页面。

<template>
  <div :style="{background:'url('+require('../../static/background.jpeg')+')'}"
       style="background: no-repeat; background-size:100% 100%;height: 100vh; overflow: hidden; position: relative" >

    <div style="width: 800px; height: 700px; border-radius: 10px;
    margin: 50px 100px;padding: 50px">
      <div style="font-size: 30px; font-weight: bold; color:#d9e7f8;
      margin-bottom: 20px">登录成功!!<br><span>倒计时{{countdown}}秒,为您跳转到首页:)</span>
        <br>
        <div style="color: #005f93; font-size: medium;"><a href="../../../public/static/homepage.html"></a>立即跳转</div>
      </div>

    </div>

  </div>
</template>

<script>

export default {
  data() {
    return {
      countdown: 5,
      timer: null
    };
  },
  methods: {

  },
  //start:倒计时5秒钟
  mounted() {
    this.timer = setInterval(() => {
      if (this.countdown > 0) {
        this.countdown--
      }
      else {
        clearInterval(this.timer)
        console.log()
        window.location.href = '../../../static/homepage.html' //需要跳转html页面的地址(或者是存放html页面的文件地址)
        // this.$router.push('/login')
      }}, 1000)
  }
  //end:倒计时5秒钟
}
</script>

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值