Gre*_*ers 1 routerlinkactive routerlink angular
页面中没有路由。我在下面使用了HTML和配置代码。
<nav aria-label="Page navigation">
<ul class="pagination pagination-plain">
<li>
<a href="review/words" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<li [routerLinkActive]="['active']">
<a [routerLink]="review/words">1</a>
</li>
<li [routerLinkActive]="['active']">
<a [routerLink]="review/phrase">2</a>
</li>
<li>
<a href="javascript:void(0)" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
Run Code Online (Sandbox Code Playgroud)
路由配置代码为
const appRoutes: Routes = [
{
path: '',
component: IndexComponent,
},
{
path: 'index',
component: IndexComponent,
},
{
path: 'review/words',
component: WordsComponent,
},
{
path: 'review/phrase',
component: SentenceComponent,
}
];
Run Code Online (Sandbox Code Playgroud)
当我在分页链接中单击“ 1”或“ 2”时,出现以下错误。
错误错误:未捕获(承诺):错误:无法匹配任何路由。URL段:'review / phrase / NaN'错误:无法匹配任何路由。网址段:ApplyRedirects.noMatchError(router.es5.js:1404)的[review / phrase / NaN]在CatchSubscriber.selector的[角度](router.es5.js:1379)在CatchSubscriber.error的[角度](catch.js) :104)在MapSubscriber.Subscriber._error(Subscriber.js:128)的[angular]在MapSubscriber.Subscriber.error(Subscriber.js:102)的[Angular]在MapSubscriber.Subscriber._error(Subscriber.js:128)的[angular] )[Subscriber.Subscriber.error(Subscriber.js:102)的[Angular] MapSubscriber.Subscriber._error(Subscriber.js:128)的[Angular] MapSubscriber.Subscriber.error(Subscriber.js:102)的[Angular] [有角的]
尝试这样的事情。
<a [routerLink]="['review/words']">1</a>
Run Code Online (Sandbox Code Playgroud)
这就是期望输入的方式。!
编辑:另外,您在html中没有路由器容器。在模板文件末尾添加它。
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5410 次 |
最近记录: |