Skip to content
导航

removeRoute

TIP

通过名称删除现有路由

removeRoute接收一个name(现有路由名称)属性。

ts
function removeRoute(name: RouteRecordName) {
  // 根据name获取对应的routeRecordMatcher
  const recordMatcher = matcher.getRecordMatcher(name)
  if (recordMatcher) {
    // 如果存在recordMatcher,调用matcher.removeRoute
    matcher.removeRoute(recordMatcher)
  } else if (__DEV__) {
    warn(`Cannot remove non-existent route "${String(name)}"`)
  }
}

对于matcher.removeRoute,参考matcher.removeRoute

removeRoute流程:

removeRoute

removeRoute has loaded