vue中setTimeout定时器的使用

迈不过友情╰ 2022-10-14 15:53 192阅读 0赞
  1. created() {
  2. if (this.timer) {
  3. clearTimeout(this.timer)
  4. }
  5. this.getCount()
  6. },
  7. methods: {
  8. // 定时器(每隔一分钟获取一次状态)
  9. getCount() {
  10. this.getrealtime()
  11. let _this = this
  12. this.timer = setTimeout(() => {
  13. _this.getCount()
  14. }, 60000)
  15. }
  16. },
  17. beforeDestroy() {
  18. clearTimeout(this.timer)
  19. }

发表评论

表情:
评论列表 (有 0 条评论,192人围观)

还没有评论,来说两句吧...

相关阅读