我使用RouterModule后不工作,我有这个在我的app.module.ts角2路AOT编译生成
const appRoutes: Routes = [
{ path: '', redirectTo: 'mainMenu', pathMatch: 'full' },
{ path: 'mainMenu', component: MainComponent,
children: [
{
path: '',
redirectTo: 'products',
pathMatch: 'full'
},
{
path: 'products',
component: ProductsComponent
}
]
},
{ path: 'targeting', component: TargetingComponent }
];
它的作品真的很好,当我在本地测试。/mainMenu/products将我带到MainComponent并包含ProductsComponent。和/ targeting将我带到TargetingComponent。
我建立
ng build --aot
在蒸馏水生成的文件放在服务器上的项目。该页面会自动重定向到/ mainMenu/products。但是,如果我在URL/mainMenu/products或/ targeting中输入,则不起作用。我得到GET /mainMenu/products" Error (404): "Not found"
或GET /targeting" Error (404): "Not found"
。所以我认为这是因为提前编译而发生的,这是真的吗?有什么我应该做的配置这个工作?
我正在使用npm http-server。
好吧,我创建了上述文件。并将其放在与index.html相同的目录中。还是一样。我错过了其他步骤吗?它如何自动知道从.htaccess文件中读取btw? – Eddy
你必须使用Apache并允许AllowOverride – al37350
我使用npm http-server,有什么想法吗? – Eddy