vue2中axios报错rror in v-on handler: "TypeError: Cannot read properties of undefined
时间: 2023-10-14 13:04:40 浏览: 184
在Vue2中,当使用axios进行请求时,如果在请求结果被catch捕获后,没有给相应的变量赋值,那么在后续使用该变量时就会出现报错"TypeError: Cannot read properties of undefined"。
要解决这个问题,只需要在catch中将axios获取到的数据赋值给相应的变量即可,这样就能避免出现未定义的情况导致的报错。确保在catch中对获取到的数据进行处理或赋值,以避免报错。<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [vue报错解决:Error in v-on handler (Promiseasync) “TypeError Cannot read properties ofundefined](https://blog.csdn.net/begefefsef/article/details/123372968)[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%"]
- *2* [ChatGPT聊天微信小程序源码适配H5和WEB端.zip](https://download.csdn.net/download/m0_66047725/88222777)[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 ]
阅读全文