我的应用程序不会直接路由到路由模块中定义的路由

时间:2019-05-29 20:43:40

标签: angular angular-routing

我的角度应用程序工作正常,除了一个问题。我可以通过导航栏单击以转到不同的路线,但是当我尝试通过搜索栏(在浏览器中)直接转到basehref时,提示未找到错误404页面。我的目标是能够通过搜索栏访问链接,而不会显示错误404。

我尝试注释掉app-routing.module.ts,但这似乎无济于事。

我不确定在这里显示什么,但这是我的import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { AppComponent } from './app.component'; import { HomeComponent } from './home/home.component'; import { AboutComponent } from './about/about.component'; import { NewsComponent } from './news/news.component'; import { FaqComponent } from './faq/faq.component'; import { BcsoComponent } from './depts/bcso/bcso.component'; import { CivComponent } from './depts/civ/civ.component'; import { SahpComponent } from './depts/sahp/sahp.component'; import { RulesComponent } from './rules/rules.component'; import { LostComponent } from './shared/lost/lost.component'; import { RequirementsComponent } from './requirements/requirements.component'; import { ContactComponent } from './contact/contact.component'; import { WipComponent } from './shared/wip/wip.component'; import { CodesComponent } from './codes/codes.component'; import { BcsosopComponent } from './depts/bcso/d/bcsosop/bcsosop.component'; import { BcsostructuresComponent } from './depts/bcso/d/bcsostructures/bcsostructures.component'; import { CivsopComponent } from './depts/civ/d/civsop/civsop.component'; import { CivstructuresComponent } from './depts/civ/d/civstructures/civstructures.component'; const routes: Routes = [ {path: '', redirectTo: '/home', pathMatch: 'full'}, // Done {path: 'home', component: HomeComponent}, // Done {path: 'about', component: AboutComponent}, // Done {path: 'news', component: NewsComponent}, // Done {path: 'faq', component: FaqComponent}, // Done {path: 'rules', component: RulesComponent}, // Done {path: 'retirement', component: RetirementComponent}, // Done {path: 'requirements', component: RequirementsComponent}, // Done {path: 'req', redirectTo: '/requirements'}, // Done {path: 'contact', component: ContactComponent}, // Done {path: 'help', redirectTo: '/contact'}, // Done {path: 'apply', redirectTo: '/wip'}, // Done {path: 'depts/bcso', component: BcsoComponent}, // Done {path: 'depts/bcso/sop', component: BcsosopComponent}, // Done {path: 'depts/bcso/structures', redirectTo: '/wip'}, {path: 'depts/civ', component: CivComponent}, // Done {path: 'depts/civ/sop', component: CivsopComponent}, // Done {path: 'depts/civ/structures', redirectTo: '/wip'}, {path: '404', component: LostComponent}, // Done {path: 'wip', component: WipComponent}, // Done {path: '**', redirectTo: '/404'}, // Done ]; @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule] }) export class AppRoutingModule { } 的摘录:

router.get('/', async (req, res, next)

预期结果是能够直接转到链接(例如example.com/help),但实际结果是这样的:

Link to Imgur for Error Image

0 个答案:

没有答案