Cannot read properties of null (reading 'ownerDocument')
时间: 2023-10-17 22:35:52 浏览: 66
当 JavaScript 代码尝试读取一个值为 null 的对象的属性时,就会出现 "Cannot read properties of null (reading 'ownerDocument')" 错误。这个错误的意思是代码尝试访问一个 null 对象的 ownerDocument 属性,但是 null 对象没有这个属性。从引用中可以了解到,如果目标节点本身是一个未与任何文档一起使用的 DocumentType,那么 "getOwnerDocument()" 方法会返回 null。从引用的例子中,我们可以看到修改文件后缀名可以解决这个问题。这是因为修改后缀名将文件类型更改为 HTML,而不是 SVG,所以代码不再尝试访问 SVG 文件的 ownerDocument 属性,从而避免了错误的发生。因此,通过将文件后缀名从 .svg 改为 .html,可以解决 "Cannot read properties of null (reading 'ownerDocument')" 的错误。<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [ownerDocument01.rar_Not Yet](https://download.csdn.net/download/weixin_42650811/86587802)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [Uncaught TypeError: Cannot read property 'ownerDocument' of null](https://blog.csdn.net/weixin_34085658/article/details/85935090)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]