vue实现几秒后跳转新页面代码
更新时间:2020年09月09日 10:02:13 作者:☞小阿平☜
这篇文章主要介绍了vue实现几秒后跳转新页面代码,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
我就废话不多说了,大家还是直接看代码吧~
<template> <div @click="clickJump()">提交</div> </template> <script> export default { data(){ return { count:"",//倒计时 } } }, mounted(){ }, methods: { //几秒后进入跳转页面 clickJump(){ const timejump = 1; if(!this.timer){ this.count = timejump ; this.show = false; this.timer = setInterval(()=>{ if(this.count > 0 && this.count <= timejump ){ this.count--; }else{ this.show = true; clearInterval(this.timer); this.timer = null; //跳转的页面写在此处 this.$router.push({path: '/address'}); } },100) } }, } </script>
补充知识:vue设置延时
一定要创建一个timer,然后调用延时之前先清除timer的延时
clearTimeout(this.timer); //清除延迟执行 this.timer = setTimeout(()=>{ //设置延迟执行 console.log('ok'); },1000);
以上这篇vue实现几秒后跳转新页面代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
使用element-ui table expand展开行实现手风琴效果
这篇文章主要介绍了使用element-ui table expand展开行实现手风琴效果,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2019-03-03
最新评论