3分钟不响应自动跳转首页 app.vue
<template>
<div id="app" class="content bg" @mousedown="clickApp">
<div class="app">
<router-view/>
</div>
</div>
</template>
<script>
import router from '@/router'
export default {
name: "App",
data() {
return {
clickTime: new Date(),
responseTime: 3 * 60 * 1000,
timeout: null,
};
},
methods: {
clickApp() {
var nowTime = new Date();
let _this = this;
if (nowTime - this.clickTime <= this.responseTime) {
clearTimeout(this.timeout);
}
this.clickTime = nowTime;
this.timeout = setTimeout(function () {
console.log("1212");
if (router.history.current.fullPath !== '/' && router.history.current.fullPath !== '/home') {
router.push("/home")
}
}, this.responseTime);
},
},
};
</script>