是否需要导入离子模块才能在自定义组件中使用离子菜单?
这是我的app.component.html
:
<ion-app>
<ion-split-pane when="xl">
<!-- our side menu -->
<mm-side-menu></mm-side-menu>
<!-- the main content -->
<ion-router-outlet main></ion-router-outlet>
</ion-split-pane>
</ion-app>
这是mm-side-menu
的html:
<p>TEST</P>
<ion-menu side="start" menuId="sideMenu">
<ion-header>
<ion-toolbar color="primary" mode="ios"> </ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
{{ pages | json }}
<ion-menu-toggle auto-hide="false" *ngFor="let page of pages">
{{ page | json }}
<mm-menu-item [link]="page"></mm-menu-item>
</ion-menu-toggle>
<ion-button>Log out</ion-button>
</ion-list>
</ion-content>
</ion-menu>
这是模块:
import { NgModule } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
import { Facebook } from '@ionic-native/facebook/ngx';
import { MmSideMenuComponent } from './mm-side-menu/mm-side-menu.component';
import { MmMenuItemComponent } from './mm-menu-item/mm-menu-item.component';
@NgModule({
declarations: [MmMenuItemComponent, MmSideMenuComponent],
imports: [IonicModule, RouterModule, CommonModule],
providers: [Facebook],
exports: [MmMenuItemComponent, MmSideMenuComponent]
})
export class SideMenuComponentModule {}
带有Test的段落标签正在呈现,因为菜单也在dom中呈现但不可见。