外观
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
流程: