angular2路由器Routes配置里的pathMatch

angular2路由器Routes配置里的pathMatch

pathMatch是一个用来指定路由匹配策略的字符串。可选项有 prefix(默认值)和 full

prefix:以指定的路径开头;

full:与指定路径完全一样。

例1:

{

​ path: ‘abc’,

​ redirectTo: ‘/tabs/tab1’,

​ pathMatch: ‘prefix’

}

  • yes:

    /abc

    /abc/

    /abc/d

  • no:

    /abcd

    /abcd/

例2:

{

​ path: ‘abc’,

​ redirectTo: ‘/tabs/tab1’,

​ pathMatch: ‘full’

}

  • y:

    /abc

    /abc/

  • n:

    /abcd

    /abcd/


由于空路径是任何 url 的前缀,下面的配置表示任意路由都可以跳转:

{

​ path: ‘’,

​ redirectTo: ‘/tabs/tab1’,

​ pathMatch: ‘prefix’

​ }

你可能感兴趣的:(前端,router,url,pathMatch,angular)