Preface
最近业务中有一个小需求是, 用户五分钟没有操作, 跳转回登录页面。
代码实现如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| let income = this.$refs.income;
let timer;
function startTimer(){ clearTimeout(timer); timer = setTimeout(function(){ window.location.href="/login.html"; }, 5 * 60 * 1000); }
income.onmousemove = income.onmousedown = income.onclick = income.ontouchstart = income.ontouchmove = income.ontouchend = startTimer;
income.onclick();
|