1.router.currentRoute
相当于$route
但是$route.path
或者$route.fullPath
只能在组件中用
组件里头:
/user?a=10` $route.path === /user $route.fullPath === /user?a=10
js
模块中要使用router.currentRoute
js模块中:router.currentRoute.value.fullPath
就是当前路由地址,router.currentRoute
是ref
响应式数据 要拿值的话需要.value
2.encodeURIComponent
转换uri
编码,防止解析地址出问题 用来解析获得的ullPath
中的特殊字符
const fullPath = encodeURIComponent(router.currentRoute.value.fullPath)