遍历定时器vue JS

vue循环遍历定时器
需要每隔1秒遍历如下代码,目前的问题是隔1秒后全部执行,请问怎么改进

startReview(){
        console.log('start')
        for(let i=0; i<this.handHistory.actions.preflop.length; i++){
            setTimeout(()=>{
              var currentSeat = this.handHistory.actions.preflop[i].seat
              var bet = this.handHistory.actions.preflop[i].chip
              var action = this.handHistory.actions.preflop[i].action
              this.player[currentSeat].currentBet = bet
              this.player[currentSeat].actionStatus = action
            },1000)
          }

          
        }

1000 改成 1000*(i+1),或者


startReview(){
                            console.log('start')
                            let i = 0;
                               const timer =  setInterval(()=>{
                                    if(i<this.handHistory.actions.preflop.length){
                                       
                                        var currentSeat = this.handHistory.actions.preflop[i].seat
                                        var bet = this.handHistory.actions.preflop[i].chip
                                        var action = this.handHistory.actions.preflop[i].action
                                        this.player[currentSeat].currentBet = bet
                                        this.player[currentSeat].actionStatus = action
                                         i++
                                    }else{
                                        clearInterval(timer)
                                    }
                                },1000)
                            }

加上一些判断,可以让代码有选择地执行某一部分。

改成同步或者把函数拆出来

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^