this.$route.path
类型: string
字符串,对应当前路由的路径,总是解析为绝对路径,如 "/foo/bar"。
this.$route.params
类型: Object
一个 key/value 对象,包含了动态片段和全匹配片段,如果没有路由参数,就是一个空对象。
this.$route.query
类型: Object
一个 key/value 对象,表示 URL 查询参数。例如,对于路径 /foo?user=1,则有 this.$route.query.user == 1,如果没有查询参数,则是个空对象。
this.$route.hash
类型: string
当前路由的 hash 值 (带 #) ,如果没有 hash 值,则为空字符串。
this.$route.fullPath
类型: string
完成解析后的 URL,包含查询参数和 hash 的完整路径。
this.$route.matched
类型: Array<RouteRecord>
一个数组,包含当前路由的所有嵌套路径片段的路由记录 。路由记录就是 routes 配置数组中的对象副本 (还有在 children 数组)。
const router = new VueRouter({
routes: [
// 下面的对象就是路由记录
{
path: '/foo',
component: Foo,
children: [
// 这也是个路由记录
{ path: 'bar', component: Bar }
]
}
]
})
当 URL 为 /foo/bar,$route.matched 将会是一个包含从上到下的所有对象 (副本)。
this.$route.name
当前路由的名称,如果有的话。(查看命名路由)
$route.redirectedFrom
如果存在重定向,即为重定向来源的路由的名字。(参阅重定向和别名)
#
组件注入
vue 路由对象属性
最新推荐文章于 2024-04-23 14:13:43 发布