vue定时调用接口
2022/4/26 6:14:18
本文主要是介绍vue定时调用接口,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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 }
这篇关于vue定时调用接口的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-09vue3开发前端表单缓存自定义指令,移动端h5必备插件
- 2024-05-09React Hooks在class组件中的使用方式
- 2024-03-30[OIDC in Action] 2. 基于OIDC(OpenID Connect)的SSO(纯JS客户端)
- 2024-03-29terraform jsonencode
- 2024-03-13vuex-persist
- 2024-03-11icons for vue
- 2024-03-07breadcrumbs react js
- 2024-03-06react login page example
- 2024-03-06react router uselocation
- 2024-03-04postgres jsonb_set