vue 清除定时器的小技巧 hook:beforeDestroy

created () {

  const timer = setInterval(() => { xxxx }, 1000);

  this.$once("hook:beforeDestroy", () => { clearInterval(timer); });

}

原文地址:https://www.cnblogs.com/evablog/p/14341595.html