学无先后,达者为师

网站首页 Vue 正文

vue 实现三秒钟倒计时 跳转页面

作者:bug生产小能手 更新时间: 2022-01-10 Vue
DOM节点: <span>{{count}}</span>
data() {
return{
count:''
}
},
created() {
    this.countDown() // 倒计时
  },
  methods: {
    countDown() {
      const TIME_COUNT = 3
      if (!this.timer) {
        this.count = TIME_COUNT
        this.timer = setInterval(() => {
          if (this.count > 1 && this.count <= TIME_COUNT) { //限制倒计时区间
            this.count--
          } else {
            clearInterval(this.timer)   //删除定时器
            this.timer = null
            //跳转的页面写在此处
            this.$router.push('/vaccineProtectionTk')
          }
        }, 1000)
      }
    },
  },

原文链接:https://blog.csdn.net/WWW_wwwww/article/details/113399767

栏目分类
最近更新