Error in v-on handler: "TypeError: Cannot read properties of undefined (reading '0')" found in
时间: 2023-09-11 21:03:49 浏览: 360
你遇到的报错信息是 "Error in v-on handler: "TypeError: Cannot read properties of undefined (reading 'then')"。这个错误通常是因为你在一个 undefined 的对象上尝试读取属性 'then'。根据你提供的引用内容,有两种方法可以解决这个问题。
方法一是在箭头函数中添加 return 关键字。这个方法对于你的代码可能不太适用,因为你尝试过随意在代码中添加 return,但并没有解决问题。在评论区可能有其他解决方法。
方法二是在方法前面添加关键字 async。这个方法使得你的代码中的报错消失了,但你不清楚原理。根据文档的介绍,使用 async function 定义的函数可以在其内部使用 await 关键字来等待一个 Promise 对象完成。这样的代码等价于一个返回 Promise.resolve(1).then(() => undefined) 的函数。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [Error in v-on handler: “TypeError: Cannot read properties of undefined (reading ‘then‘)](https://blog.csdn.net/weixin_56762709/article/details/125620213)[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: 100%"]
[ .reference_list ]