vue實現(xiàn)幾秒后跳轉(zhuǎn)新頁面代碼
我就廢話不多說了,大家還是直接看代碼吧~
<template> <div @click='clickJump()'>提交</div></template><script>export default { data(){ return { count:'',//倒計時 } }}, mounted(){ }, methods: { //幾秒后進入跳轉(zhuǎn)頁面 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;//跳轉(zhuǎn)的頁面寫在此處this.$router.push({path: ’/address’}); } },100) } },}</script>
補充知識:vue設置延時
一定要創(chuàng)建一個timer,然后調(diào)用延時之前先清除timer的延時
clearTimeout(this.timer); //清除延遲執(zhí)行 this.timer = setTimeout(()=>{ //設置延遲執(zhí)行 console.log(’ok’);},1000);
以上這篇vue實現(xiàn)幾秒后跳轉(zhuǎn)新頁面代碼就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. CSS hack用法案例詳解2. ASP.NET Core實現(xiàn)中間件的幾種方式3. 使用HttpClient增刪改查ASP.NET Web API服務4. JSP servlet實現(xiàn)文件上傳下載和刪除5. input submit、button和回車鍵提交數(shù)據(jù)詳解6. 怎樣才能用js生成xmldom對象,并且在firefox中也實現(xiàn)xml數(shù)據(jù)島?7. 詳解盒子端CSS動畫性能提升8. 怎樣打開XML文件?xml文件如何打開?9. 詳解瀏覽器的緩存機制10. Jsp+Servlet實現(xiàn)文件上傳下載 刪除上傳文件(三)
