TypeError: Cannot read properties of undefined (reading 'mediaAccountsTable')
时间: 2023-10-17 10:31:04 浏览: 107
TypeError: Cannot read properties of undefined (reading 'mediaAccountsTable') 是因为在访问 `store.user.state.userInfo.data.mediaAccountsTable` 时,`mediaAccountsTable` 是未定义的属性。这个错误通常是由于 `userInfo` 对象中的 `data` 属性未正确设置导致的。引用中提到了一个解决方法,可以在 `userInfo` 对象下添加一个 `data` 属性并初始化为空对象,例如:
```javascript
state: {
userInfo: {
data: {
mediaAccountsTable: {}
}
}
}
```
通过这种方式,即使 `userInfo` 未定义或为空对象,访问 `mediaAccountsTable` 属性时也不会报错。这样可以避免出现 `TypeError: Cannot read properties of undefined (reading 'mediaAccountsTable')` 错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [解决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_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文