Skip to content

RouteLocation

“标准化后的路由对象”,也就是 Vue Router 内部真正使用的结构。

RouteLocationRaw = 输入(原始地址) RouteLocation = 输出(解析结果)

使用router.resolve可以将RouteLocationRaw ->RouteLocation

Properties

字段说明类型来源
fullPath完整路径,包括 query/hashstring拼接 path + query + hash
path规范化后的路径string基于 pathname 解析生成
name路由名称string | undefined如果 RouteRecordRaw 有 name 则带上
params动态参数Record<string, any>补全了缺失的参数
query查询参数Record<string, any>补全默认空对象
hashhashstring补全默认空字符串
matched匹配的路由记录数组RouteRecord[]解析匹配的 RouteRecordRaw
metameta 信息Record<string, any>从 matched 合并而来
redirectedFrom重定向来源RouteLocation | undefined如果有 redirect
href可用于 <a> 标签的完整路径stringfullPath 编码后的结果