1、使用命令创建组件
ionin g component tabBar
2、在app,module.ts中引入component.module.ts,并添加到imports中
import { ComponentsModule } from '../components/components.module'
imports: [
BrowserModule,
FormsModule,
ComponentsModule,
HttpModule,
IonicModule.forRoot(MyApp, {
tabsHideOnSubPages: "true" //隐藏全部子页面tabs
}),
IonicStorageModule.forRoot()
],
3、这时候在子组件中使用angular语法可能会报错,这时候在component.module.ts中添加CommonModule
import { CommonModule } from '@angular/common';
@NgModule({
declarations: [TabBarComponent],
exports: [TabBarComponent],
imports:[CommonModule]
})
4、在父组件中可以直接使用
<tab-bar></tab-bar>