Uncaught TypeError: Cannot read property 'DYMC' of null
程序员文章站
2022-03-27 13:09:14
...
var arr = [null,{"ADDR":"","BZ":"","CZSJ":"","DYMC":"哈哈","FJH":"","GRMJ":"","GRQ":"","GRQF":0,"KH":"","LHMC":"","QFJE":0,"SFLX":"","TRQF":0,"XQMC":"","YHBH":"","YHLB":"","YHXM":"","ZNJ":0}]
for(var i in arr){
console.log(arr[i].DYMC);
}
报错
Uncaught TypeError: Cannot read property 'DYMC' of null
at 1.html:13
原因数组遍历是因为有null
更改:
var arr = [null,{"ADDR":"","BZ":"","CZSJ":"","DYMC":"哈哈","FJH":"","GRMJ":"","GRQ":"","GRQF":0,"KH":"","LHMC":"","QFJE":0,"SFLX":"","TRQF":0,"XQMC":"","YHBH":"","YHLB":"","YHXM":"","ZNJ":0}]
for(var i in arr){
if(arr[i]!=null){
console.log(arr[i].DYMC);
}
}
推荐阅读
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object
-
npm ERR! Cannot read property 'path' of null
-
js报错 Cannot read property 'getAttribute' of null
-
Extjs4---Uncaught TypeError: Cannot read property ‘items’ of undefined
-
JavaScript Uncaught TypeError: Cannot read property 'value' of null
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#
-
el-tooltip组件中content使用Vue-i18n报错TypeError: Cannot read property ‘$t‘ of null
-
vuejs路由使用的问题Error in render function: "TypeError: Cannot read property 'matched' of undefined"
-
Extjs4 tabPanel关闭后打开 cannot read property addcls of null
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object