vue页面长时间操作返回首页

<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script>




export default {
  name: "App",
  data(){
    return {
      timeOut:''
    }
  },
  mounted(){
    this.isTimeOut();

  },
  methods:{
    startTimer() {
      let that = this;

      clearInterval(that.timeOut);
      that.timeOut = setInterval(()=> {
        that.$router.push({path:'/mapnaviga'})
      },1000*60*15)
    },
    isTimeOut() {
      let that = this;

      if(that.$route.path == "/") {
        that.startTimer();
      }
      document.body.onmouseup = that.startTimer;
      document.body.onmousemove = that.startTimer;
      document.body.onkeyup  = that.startTimer;
      document.body.onclick  = that.startTimer;
      document.body.ontouchend  = that.startTimer;
    },
  },
  watch:{
    '$route'(to,from){
      if(to.path==from.path){
        console.log(to, from);
        this.$router.push('mapnaviga')
      }
    }
  }
};
</script>
<style src="./base/css/base.css"></style>
发布了76 篇原创文章 · 获赞 8 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_43453916/article/details/100559987
今日推荐