我正试图在我的工作中实现星云,所以我正在遵循这星云教程进行锻炼。
我安装了星云。它在<nb-layout>
<nb-header>
中运行良好,但是当我使用<nb-actions>
或<nb-menu>
时,它会抛出以下错误
compiler.js:1021 Uncaught Error: Template parse errors:
'nb-action' is not a known element:
1. If 'nb-action' is an Angular component, then verify that it is part of this module.
2. If 'nb-action' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this
我不知道是怎么回事。怎么修呢?
side.html
<nb-layout>
<nb-layout-header subheader>
<nb-actions>
<nb-action icon="nb-home"></nb-action>
<nb-action icon="nb-search"></nb-action>
<nb-action icon="nb-edit"></nb-action>
</nb-actions>
</nb-layout-header>
</nb-layout>
side.ts //组件
import {Component} from '@angular/core';
@Component({
selector:"sidebar",
templateUrl:"./side.html",
styleUrls:["side.css"]
})
export class sideComponent{
}
sbar.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule,Routes } from '@angular/router';
import { NbSidebarModule, NbLayoutModule, NbSidebarService } from '@nebular/theme';
import {sideComponent} from "./sidecomp/side";
const routes: Routes = [{path:"sidebar",component:sideComponent}]
@NgModule({
declarations:[
sideComponent
],
imports: [
CommonModule,
RouterModule.forRoot(routes, { useHash: true }),
NbSidebarModule,
NbLayoutModule
],
providers:[NbSidebarService],
exports:[sideComponent]
})
export class SbarModule { }
发布于 2018-09-08 08:04:42
确保您已经导入了NbLayoutModule
@NgModule({
imports: [
NbSidebarModule,
NbLayoutModule
]
另外,您的错误显示为nb-action,而应该是nb-actions
,,请确保您没有错误。
编辑
您还需要导入NbActionsModule
。检查代码这里
发布于 2018-12-06 19:24:11
您必须在应用程序模块以及任何子模块中导入NbLayoutModule。
@NgModule({
imports: [
// ...
NbLayoutModule.forRoot(),
],
})
export class AppModule { }
在您的子模块中导入
@NgModule({
imports: [
// ...
NbLayoutModule,
],
})
export class PageModule { }
发布于 2021-10-05 19:06:25
根据文档,只需使用按钮
<nb-card>
<nb-card-header>Button</nb-card-header>
<nb-card-body class="example-items-rows">
<button nbButton>Active</button>
<button nbButton disabled>Disabled</button>
</nb-card-body>
</nb-card>
https://stackoverflow.com/questions/52233203
复制相似问题