Skip to content
导航

hasRoute

TIP

根据名称查找是否有对应的路由

hasRoute接收一个name字符串,返回一个boolen值。通过matcher.getRecordMatcher来获取对应的routeRecordMatcher,在matcher.getRecordMatcher会在matcherMap中取寻找对应的routeRecordMatcher,如果没有找到说明路由不存在

ts
function hasRoute(name: RouteRecordName): boolean {
  return !!matcher.getRecordMatcher(name)
}

matcher.getRecordMatcher的实现可参考:matcher.getRecordMatcher

hasRoute has loaded