【发布时间】:2019-07-12 10:25:12
【问题描述】:
本地主机上的路由有效,我也可以从路由访问,而不仅仅是从索引 www.myhost.com/route1 在本地主机上工作 www.myhost.com => www.myhost.com/route1 在我的家庭服务器上工作(我有公共 ip) www.myhost.com/route1 不起作用 => 给我 NOT FOUND
我使用 ng build --prod --watch 构建 我尝试 PathLocationStrategy 我尝试 APP_BASE_HREF 我试试 LocationStrategy
base 设置为“/”
我尝试了 useHash,它可以工作,但真的很难看。
const appRoutes: Routes = [
{path: '', pathMatch: 'full', component: MatchListComponent},
{path: 'match/:id', component: MatchDetailComponent},
{path: 'team/:id', component: TeamDetailComponent}
];
@NgModule({
declarations: [
AppComponent,
MatchListComponent,
MatchDetailComponent,
TeamDetailComponent
],
imports: [
BrowserModule,
HttpClientModule,
NgbModule,
RouterModule.forRoot(appRoutes, {scrollPositionRestoration : 'enabled'})
],
providers: [{provide: PathLocationStrategy}],
bootstrap: [AppComponent]
})
export class AppModule { }
我尝试了一些角度 2 或 4 的解决方案,但它们不起作用。 我的网络服务器是 Apache2
【问题讨论】:
-
那么 useHash 有用吗?
标签: angular deployment angular7 angular-router