Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'replace')
时间: 2023-10-17 22:25:21 浏览: 165
Vue打包Cannot read property 'tapPromise' of undefined报错处理.docx
5星 · 资源好评率100%
当你在访问`store.user.state.userInfo.data.id`时,如果`userInfo`是一个空对象,那么`store.user.state.userInfo.data`会返回`undefined`。但是,当你继续访问`store.user.state.userInfo.data.id`时,会导致控制台报错,报错信息为`Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')`。这是因为你正在尝试读取一个`undefined`对象的`id`属性。
类似的报错信息也可以出现在其他情况下。比如,在黑马的人资项目中,如果要读取`store`中的`userInfo`对象的`id`值时,也会出现类似的报错信息`Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')`。原因可能是在异步请求中出现了问题,导致`userInfo`对象没有正确地被赋值。
此外,有时候在相同的网站上的某些页面,客户端验证能正常工作,而其他页面却会出现`Uncaught TypeError: Cannot set property __MVC_FormValidation of null`的错误。这个错误可能是由于某些页面的特定代码或配置问题导致的,具体原因需要针对具体页面进行排查。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [解决Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘id‘)报错](https://blog.csdn.net/m0_57524265/article/details/131441971)[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_2"}}] [.reference_item style="max-width: 50%"]
- *3* [ASP.NET MVC运行出现Uncaught TypeError: Cannot set property __MVC_FormValidation of null的解决方法](https://download.csdn.net/download/weixin_38731761/13069683)[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_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文