毕设-微信商城遇到的问题(2018/4/7)

2018/4/7
1.【问题】commercialList:109 Uncaught TypeError: Cannot read property ‘pro_id’ of undefined
【解析】如果是在for循环下出现的这种问题,那么就是要考虑访问数组是不是越界了的问题。参考写JS报错“Cannot read property ‘style’ of undefined”,是什么原因?

  for (var i = 0; i <=countList; i++) {
     .....
 }

假设countList = 5.而数组arr下标从0开始,0,1,2,3,4是五个数,根据上面的代码,会访问到arr[5],但是没有arr[5],所以才会Undefined.将等号去掉就好了。

猜你喜欢

转载自blog.csdn.net/sinat_35803474/article/details/79848612