data() { return { currentTime: new Date().getTime() }; }, methods: { OperatingWebsite() { let currentTime = this.currentTime; console.log(currentTime, "currentTime"); let lastTime = new Date().getTime(); console.log(lastTime, "lastTime"); let timeOut = 10 * 60 * 1000; //設置時間 10分鐘 if (lastTime - currentTime > timeOut) { // 未操做頁面,跳轉登陸頁面 this.currentTime = new Date().getTime(); const fullPath = this.$route.fullPath; const query = this.$Base64.encode(fullPath); this.$router.push({ path: "/user", query: { type: query } }); } else { this.currentTime = new Date().getTime(); } } }
1 <div id="app" @mouseover="OperatingWebsite()" > 2 <router-view/> 3 </div>