typescript 如何在Nebular中正确实现侧栏?

ee7vknir  于 2022-11-30  发布在  TypeScript
关注(0)|答案(1)|浏览(176)

当我添加侧边栏时,它显示一个空白页面。它不给我任何错误信息。如果我删除它,它会恢复正常。
Screenshot when I don't add the sidebarScreenshot when I added the sidebar显示器
home.component.html

<nb-layout windowMode>
    <nb-layout-header fixed>
        <nb-form-field>
            <nb-icon nbPrefix icon="search-outline"></nb-icon>
            <input type="text" nbInput fullWidth shape="round" placeholder="Search">
        </nb-form-field>
        <button nbButton outline shape="round" size="medium" status="primary"><nb-icon icon="plus-outline"></nb-icon>Upload</button>
        <nb-actions>
            <nb-action title="Messages" icon="message-circle-outline" badgeDot badgePosition="top right" badgeStatus="danger"></nb-action>
            <nb-action title="Notifications" icon="bell-outline" badgeDot badgePosition="top right" badgeStatus="danger"></nb-action>
        </nb-actions>
        <nb-user size="medium" name="Tzuyu Chou" picture="https://i.pinimg.com/originals/98/98/c6/9898c6313b8270b8dcc4269c47c3ef9a.jpg"></nb-user>
    </nb-layout-header>
    <nb-sidebar></nb-sidebar>
    <nb-layout-column>Content</nb-layout-column>
</nb-layout>

home.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HomeComponent } from './home.component';
import { NbActionsModule, NbButtonModule, NbContextMenuModule, NbFormFieldModule, NbIconModule, NbInputModule, NbLayoutModule, NbMenuModule, NbSearchModule, NbSidebarModule, NbTabsetModule, NbUserModule } from '@nebular/theme';
import { RouterModule } from '@angular/router';


@NgModule({
  declarations: [
    HomeComponent
  ],
  imports: [
    CommonModule,
    RouterModule,
    NbLayoutModule,
    NbActionsModule,
    NbIconModule,
    NbContextMenuModule,
    NbTabsetModule,
    NbButtonModule,
    NbSearchModule,
    NbUserModule,
    NbFormFieldModule,
    NbInputModule,
    NbSidebarModule,
    NbMenuModule,
  ]
})
export class HomeModule { }

我只是想在我的项目中添加一个侧边栏。我按照文档中的代码操作,但仍然不起作用。

uqxowvwt

uqxowvwt1#

将NbSidebarService添加到提供程序列表

@NgModule({
  ...
  providers: [NbSidebarService],
  ...
})
export class AppModule {}

相关问题