<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>