“无法读取属性'xxx'的null” [英] "Cannot read property 'xxx' of null"
本文介绍了“无法读取属性'xxx'的null”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有孩子的文档片段,我想循环(如果可能的话)。这导致错误无法读取属性'xxx'为null。
I've got a document fragment with children that I want to loop over (when possible). This is causing an error "Cannot read property 'xxx' of null".
如何测试是否会出现这种情况?
How do I test if this will be the case?
推荐答案
您可能需要执行以下操作:
You may want to do the following:
if ((documentFragment !== null) && documentFragment.hasOwnProperty('xxx')) {
// handle property xxx of documentFragment as required
}
这篇关于“无法读取属性'xxx'的null”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文