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

简介: Cannot read properties of undefined (reading ‘$router‘)

今天在敲代码的时候,又遇到了一个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博客

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

相关文章
|
3月前
|
存储 JavaScript 前端开发
成功解决:Cannot read properties of undefined (reading ‘commit‘)
这篇文章提供了解决Vuex中"Cannot read properties of undefined (reading 'commit')"错误的两种方法:检查模板中的数据属性是否存在,以及确保在Vue实例中正确挂载了store对象。
成功解决:Cannot read properties of undefined (reading ‘commit‘)
|
3月前
|
定位技术 Apache
Echarts——Invalid geoJson format Cannot read property 'length' of undefined
Echarts——Invalid geoJson format Cannot read property 'length' of undefined
82 0
|
3月前
|
JavaScript
VUE——filemanager-webpack-plugin报错TypeError: Cannot read property 'isFile' of undefined
VUE——filemanager-webpack-plugin报错TypeError: Cannot read property 'isFile' of undefined
70 0
|
5月前
|
前端开发 小程序 JavaScript
微信小程序-Unhandled promise rejection TypeError: Cannot read property ‘get‘ of undefined
微信小程序-Unhandled promise rejection TypeError: Cannot read property ‘get‘ of undefined
|
6月前
|
资源调度 前端开发
编译第三方前端项目时候出现Syntax Error: TypeError: Cannot set properties of undefined (setting ‘parent‘)
编译第三方前端项目时候出现Syntax Error: TypeError: Cannot set properties of undefined (setting ‘parent‘)
467 0
|
3月前
|
前端开发 JavaScript
VUE——Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined
VUE——Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined
55 0
TypeError: Cannot set properties of undefined (setting ‘resdata‘),res定义数据出现的问题,定义的方法用this换成that
TypeError: Cannot set properties of undefined (setting ‘resdata‘),res定义数据出现的问题,定义的方法用this换成that
Cannot read properties of undefined (reading ‘row‘)
Cannot read properties of undefined (reading ‘row‘)
Cannot read properties of undefined (reading ‘post‘)
Cannot read properties of undefined (reading ‘post‘)
|
4月前
|
JavaScript
element-ui Cannot read properties of undefined (reading ‘name‘),data中写成集合的形式
element-ui Cannot read properties of undefined (reading ‘name‘),data中写成集合的形式