vue實(shí)現(xiàn)幾秒后跳轉(zhuǎn)新頁(yè)面代碼
我就廢話不多說了,大家還是直接看代碼吧~
<template> <div @click='clickJump()'>提交</div></template><script>export default { data(){ return { count:'',//倒計(jì)時(shí) } }}, mounted(){ }, methods: { //幾秒后進(jìn)入跳轉(zhuǎn)頁(yè)面 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)的頁(yè)面寫在此處this.$router.push({path: ’/address’}); } },100) } },}</script>
補(bǔ)充知識(shí):vue設(shè)置延時(shí)
一定要?jiǎng)?chuàng)建一個(gè)timer,然后調(diào)用延時(shí)之前先清除timer的延時(shí)
clearTimeout(this.timer); //清除延遲執(zhí)行 this.timer = setTimeout(()=>{ //設(shè)置延遲執(zhí)行 console.log(’ok’);},1000);
以上這篇vue實(shí)現(xiàn)幾秒后跳轉(zhuǎn)新頁(yè)面代碼就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 原生js實(shí)現(xiàn)的觀察者和訂閱者模式簡(jiǎn)單示例2. asp讀取xml文件和記數(shù)3. JS錯(cuò)誤處理與調(diào)試操作實(shí)例分析4. JS實(shí)現(xiàn)表單中點(diǎn)擊小眼睛顯示隱藏密碼框中的密碼5. python基于scrapy爬取京東筆記本電腦數(shù)據(jù)并進(jìn)行簡(jiǎn)單處理和分析6. Python ellipsis 的用法詳解7. 在終端啟動(dòng)Python時(shí)報(bào)錯(cuò)的解決方案8. Python如何實(shí)現(xiàn)感知器的邏輯電路9. 基于android studio的layout的xml文件的創(chuàng)建方式10. PHP實(shí)現(xiàn)基本留言板功能原理與步驟詳解
