假设当前路由地址是:/user?a=10
在组件里面(index.vue)
- $route.path ===> /user
- $route.fullPath ===> /user?a=10
在JS模块中
在vue2.0
- router.currentRoute.fullPath ===> /user?a=10
在vue3.0
- router.currentRoute.value.fullPath ===> /user?a=10
$route和$router的区别???????
- $route是路由信息对象,只能读,对象包括path、params、hash、query、fullPath、matched、name等路由信息对象。
- $router是路由实例,只能操作,包括路由跳转方法,钩子函数等。