<script>
  export default {
    data() {
      return {
        list: []  // 获取的数据列表
      }
    }
    created() {
      this.getData()
    }
    methods: {
      // 这是获取数据的函数
      getData() {
        .....
      }
      // 这是一个定时器
      timer() {
        return setTimeout(()=>{
          this.getData()
        },5000)
      }
    },
    watch: {
      list() {
      this.timer() 
      }
    }
    destroyed() {
  clearTimeout(this.timer)
    }
  }
</script>

 

相关文章:

  • 2021-11-09
  • 2022-12-23
  • 2021-11-14
  • 2021-07-10
猜你喜欢
  • 2022-12-23
  • 2022-01-13
  • 2021-11-26
  • 2021-11-19
  • 2021-11-05
  • 2022-12-23
  • 2021-11-19
相关资源
相似解决方案