Cannot read properties of undefined (reading ‘$router‘)

本文讲述了作者在Vue项目中遇到的$router.push路由跳转错误,解决了由于未正确导入和使用router的问题,并提到如何在跳转时传递参数。
摘要由CSDN通过智能技术生成

今天在敲代码的时候,又遇到了一个bug

这里自己使用了,this.@router.push进行跳转的

这里感谢博主大佬的资料猿如意大佬的资料,找到问题的答案了

vue中this.$router.push 路由跳转提示错误 Cannot read properties of undefined (reading ‘push‘)_cannot read properties of undefined (reading 'push-CSDN博客


 


资料链接:

vue中this.$router.push 路由跳转提示错误 Cannot read properties of undefined (reading ‘push‘)_cannot read properties of undefined (reading 'push-CSDN博客

在当前页面使用import 引入router

import router from '@/router'; 

之后再改成这样的写法:就可以跳转了 router.push('/login')

跳转成功,bug解决

以上只能跳转,但是不能传参,感谢吃饱了撑死大佬的提醒,传参资料可参考vue3关于路由query传参_vue3 $route.query.-CSDN博客

希望能够对小伙伴有所帮助

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱你三千遍斯塔克

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值