我在我的應用中遇到路由問題。在我的本地所有作品中,但不在服務器上。該程序有以下路線:Angular 4中的路由選擇
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'login', component: LoginComponent },
{ path: 'register', component: RegisterComponent },
{ path: 'thankyou', component: ThankyouComponent },
{ path: 'home', component: UserHomeComponent, canActivate: [AuthGuard] },
{ path: 'publish', component: PublishComponent, canActivate: [AuthGuard] },
{ path: '**', component: PageNotFoundComponent }
];
該root route
始終有效。
如果我的電腦上我直接發送請求,例如,路線:
http://localhost:4200/publish
假設我已經登錄不存在任何問題加載它。但是,如果在服務器中使用路由執行該路由:
http://myserver/mypath/dist/publish
找不到路由。
我修改了index.html,以便在服務器上執行。
<base href="/">
通過<base href="/mypath/dist/">
如果我使用指令
routerLink="/publish"
它工作正常執行由HTML模板這條路。
有誰知道爲什麼會發生這種情況?
你在哪裏定義了'myserver/mypath/dist /'?我沒有看到你的問題。 –
該路線是我擁有投影源的服務器路徑 – cointreau17
你會發布處理傳入路線的代碼嗎? –