1 mounted:function(){
2 //实时监控调用是否登录接口
3 //定时器
4 const timer = setInterval(() => {
5 this.isLogin();//你所加载数据的方法
6
7 }, 610000)//秒查询一次是否登录
8 //销毁定时器
9 this.$once('hook:beforeDestroy', () => {
10 clearInterval(timer)
11 })
12 },
13
14
15 isLogin () { axios.get('http://localhost:8080/getSessionLogin',).then(function (response) {
16 console.log(response);
17 if (response.status === 200) {
18 if (response.data === ''){
19 window.location.href = 'http://localhost:8080/login';
20 }
21 }
22 }).catch(function (err) {
23 console.log(err);
24 window.location.href = 'http://localhost:8080/login';
25 });
26 }