当我在循环遍历dom元素的时候,报了想下面这种错误
     
     
      Uncaught TypeError: Cannot read properties of undefined (reading 'classList')
     
    
我的代码是这样的
                allStopVfor(tdClass) {
                    setTimeout(() => {
                        const tdStopVfor = document.querySelectorAll(tdClass)
                        for (let i = 1; i <= tdStopVfor.length; i++) {    
                            tdStopVfor[i].classList.add('active')
然后在别的地方调用了它,最后控制台一直报那种错误
最后我在添加classList.add 之前添加了个判断
                allStopVfor(tdClass) {
                    setTimeout(() => {
                        const tdStopVfor = document.querySelectorAll(tdClass)
                        for (let i = 1; i <= tdStopVfor.length; i++) {
                            if (tdStopVfor[i]) {
                                tdStopVfor[i].classList.add('active')
最后问题解决了
最后的可能因素,应该是数据的问题吧


