如果网址无效,则重定向到同一页面

问题描述 投票:0回答:1

我正在尝试重定向到同一页面,以防用户决定在该页面上输入无效的URL。到目前为止,我没有用。这样甚至可行吗?

const routes: Routes = [
  { path: '',
  component: ResultsComponent,
  children: [
  { path: '**', redirectTo: 'results' }]}] 
angular angular-ui-router
1个回答
0
投票

您需要将结果名称写入ResultsComponent的路径中

const routes: Routes = [
  { path: 'results',
  component: ResultsComponent,
  children: [
  { path: '**', redirectTo: 'results' }]}] 
© www.soinside.com 2019 - 2024. All rights reserved.