UrlMatcher

A function matching URLs

用于匹配 URL 的函数

type UrlMatcher = (segments: UrlSegment[], group: UrlSegmentGroup, route: Route) => UrlMatchResult;

说明

A custom URL matcher can be provided when a combination of path and pathMatch isn't expressive enough.

pathpathMatch 的组合无法满足需求时,可以提供一个自定义的 URL 匹配器。

For instance, the following matcher matches html files.

比如,下列匹配器会匹配 html 文件。

export function htmlFiles(url: UrlSegment[]) { return url.length === 1 && url[0].path.endsWith('.html') ? ({consumed: url}) : null; } export const routes = [{ matcher: htmlFiles, component: AnyComponent }];