我正在使用角度通用,但找不到用于仅对某些页面(如主页)使用服务器端渲染并以标准角度方式渲染所有其他路线的选项。我不想在不需要SEO的私有页面上使用服务器端渲染。我可以这样配置快速路由
// send all requests to Angular Universal
// if you want Express to handle certain routes (ex. for an API) make sure you adjust this
app.get('/', ngApp);
app.get('/home', ngApp);
app.get('/about', ngApp);
Run Code Online (Sandbox Code Playgroud)
理想情况下,我完全不需要了解NodeJ,并使用有如serverSide这样的属性在有角路由配置中对其进行配置:true
const appRoutes: Routes = [
//public route, I want server rendering for SEO
{ path: 'home', component: HomeComponent, serverSide: true },
//private user profile page, SEO is not needed
{ path: 'user/profile/:id', component: UserProfileComponent },
];
Run Code Online (Sandbox Code Playgroud)