UrlMatcher

用于匹配 URL 的函数

A function matching URLs

查看"说明"...

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

说明

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

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

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

For instance, the following matcher matches html files.

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

export const routes = [{ matcher: htmlFiles, component: AnyComponent }];