[Vue warn]: Error in v-on handler: "TypeError: Cannot read properties of null (reading '$router')"
时间: 2023-11-01 13:20:32 浏览: 403
这个报错是因为在点击事件处理函数中使用了this.$router,但是this.$router为null导致的。根据引用中提供的解决方案,可以尝试使用this.$router.replace(this.path)来跳转页面。但是由于可能会抛出错误,所以使用.catch(err => err)来捕获错误。另外,引用中提到,如果你使用的是脚手架2,删除.catch(err => err)反而会报错,而脚手架3可以删除这部分代码。因此,你可以尝试删除.catch(err => err)这一行代码来解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [(vue-cli3)[Vue warn]: Error in v-on handler: “TypeError: Cannot read property ‘catch‘ of ...](https://blog.csdn.net/weixin_44009082/article/details/119847350)[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* [vue报错:Error in v-on handler: “TypeError: handler.apply is not a function](https://blog.csdn.net/Cici__zc/article/details/118459704)[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 ]
阅读全文