【问题标题】:How do I have two pages with different base html?我如何拥有两个具有不同基本 html 的页面?
【发布时间】:2020-10-10 12:14:18
【问题描述】:

我有一个带有<router-outlet></router-outlet> 的 app.component.html 文件。这显然意味着我的所有其余组件都使用 app.component.html 作为它们的基本 html 容器。

但是我想要一个需要不同 html 布局的登录页面(可能还有其他几个页面)。

我该怎么做?

【问题讨论】:

标签: angular


【解决方案1】:

如果您在主应用程序组件路由下声明登录页面组件和这几个页面,只需将它们添加到 children 数组中,它们的基本基本 url你的应用组件。

您可以在路由数组中为没有应用组件作为其父组件的登录组件添加其他条目。

例如:

const appRoutes: Routes = [

//Site routes goes here 
{ 
    path: '', 
    component: MainComponent,
    children: [
      { path: '', component: HomeComponent, pathMatch: 'full'},
      { path: 'about', component: AboutComponent }
    ]
},
 { path: 'login', component: LoginComponent}
]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多