问题:在页面上添加了动画,切换页面后会报错,如下图:
报错是因为离开有动画的页面后,没有取消动画
// requestAnimationFrame方法启动的动画 this.timeIndex = requestAnimationFrame((time) => draw(time, canvas, ctx)); // 销毁前取消动画 beforeDestroy() { cancelAnimationFrame(this.timeIndex); },