vue 中使用setTimeout刷新存在没有清除

1、问题:想自己写个最简单类似歌词的显示(不用实现滚动,突出的部分移动就行)
2、代码:

 var n = 1
 this.soeIndex = 0
 window.clearTimeout(this.clearTime);
 this.svgShow.svgSoe.forEach((soeItem, soeIndex) => {
       n = parseInt(soeItem.time)
       this.clearTime = setTimeout(() => {
          this.soeIndex = soeIndex
        }, 1000 * n);
 })

使用setTimeout可以做到突出部分安装时间移动即可
3、遇到问题的描述:我现在想加一个刷新在上面,刷新后重新执行上面这个,但是刷新后之前的延迟加载还存在,就会导致到处跳动。用到了( window.clearTimeout(this.clearTime);)不行
求解提供思路?

你是for循环啊,所以你只保存了最后一个的setTimeOut的id,试试用数组来保存setTimeOut返回值?

你应该需要用到的是另外一个。而且不能用循环,用一个全局的变量来表示下标。每次执行结果后给下标+1