前端实现定时任务
作者:互联网
<template> <section> <h1>hello world~</h1> </section> </template> <script> export default { data() { return { timer: '', value: 0 }; }, methods: { get() { console.log('你好'); } }, mounted() { // 每隔5s发送一次 this.timer = setInterval(this.get, 5000); }, beforeDestroy() { clearInterval(this.timer); } }; </script>
标签:methods,get,前端,beforeDestroy,clearInterval,timer,任务,export,定时 来源: https://www.cnblogs.com/zhangshijiezsj/p/14180626.html