vue實(shí)現(xiàn)幾秒后跳轉(zhuǎn)新頁面代碼
我就廢話不多說了,大家還是直接看代碼吧~
<template> <div @click='clickJump()'>提交</div></template><script>export default { data(){ return { count:'',//倒計(jì)時 } }}, mounted(){ }, methods: { //幾秒后進(jìn)入跳轉(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>
補(bǔ)充知識:vue設(shè)置延時
一定要創(chuàng)建一個timer,然后調(diào)用延時之前先清除timer的延時
clearTimeout(this.timer); //清除延遲執(zhí)行 this.timer = setTimeout(()=>{ //設(shè)置延遲執(zhí)行 console.log(’ok’);},1000);
以上這篇vue實(shí)現(xiàn)幾秒后跳轉(zhuǎn)新頁面代碼就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. jsp實(shí)現(xiàn)簡單用戶7天內(nèi)免登錄2. xml文件的結(jié)構(gòu)解讀第1/2頁3. ASP 連接Access數(shù)據(jù)庫的登陸系統(tǒng)4. CSS3實(shí)例分享之多重背景的實(shí)現(xiàn)(Multiple backgrounds)5. 怎樣打開XML文件?xml文件如何打開?6. ASP基礎(chǔ)入門第二篇(ASP基礎(chǔ)知識)7. 父div高度不能自適應(yīng)子div高度的解決方案8. ASP.NET MVC實(shí)現(xiàn)登錄后跳轉(zhuǎn)到原界面9. ASP.NET MVC使用JSAjaxFileUploader插件實(shí)現(xiàn)單文件上傳10. 讓 Asp 與 XML 交互
