js报错,Uncaught TypeError: Cannot read property 'length' of undefined,没有明确错误行数,找错过程以及解决错误...

本文针对JavaScript中出现的“Cannot read property 'length' of undefined”错误进行了解析,并分享了一种排查及修复策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

M4040 jquery-1.7.2.min.js:2 Uncaught TypeError: Cannot read property 'length' of undefined
at Function.each (VM4040 jquery-1.7.2.min.js:2)
at Object.success (*****)
at o (VM4040 jquery-1.7.2.min.js:2)
at Object.fireWith [as resolveWith] (VM4040 jquery-1.7.2.min.js:2)
at w (VM4040 jquery-1.7.2.min.js:4)
at XMLHttpRequest.d (VM4040 jquery-1.7.2.min.js:4)
each @ VM4040 jquery-1.7.2.min.js:2

刚开始以为是一个变量无值(undefined),程序中js获取这个变量的length所以才会报这个错,可是查询整个页面发现调用length的变量不是确定有值就是根本没有执行,所以排除猜想的错误。

然后百度了一下,看了看别人出现类似问题的原因,再根据第二行each由此怀疑是一遍变量无值undefined但是却调用了each方法,按照这个思路查询了可能之执行的each,找到问题,添加对变量==undefined的判断。

转载于:https://www.cnblogs.com/love-dream-88/p/11201350.html

我用了方案1,现在报错了:12:42:58.678 跳转登录页成功 at pages/index/index.vue:16 12:43:07.960 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:07.960 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:07.960 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:07.960 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:07.960 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.012 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.012 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.012 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.012 [JS Framework] Failed to execute the callback function: TypeError: Cannot read property 'left' of null 12:43:08.012 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.012 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.012 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.013 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.013 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.013 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.013 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.013 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.013 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7 12:43:08.013 reportJSException >>>> exception function:__WEEX_CALL_JAVASCRIPT__, exception:JavaScript execute error!Uncaught TypeError: Cannot read property 'left' of null at (app-service.js:1701:40) 12:43:08.013 Uncaught TypeError: Cannot read properties of undefined (reading '$') at uni-app-view.umd.js:7
最新发布
07-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值