ionic+angulars app启动流程解析

ionic start myApp tabs后会创建一个工程包如下:


1.hooks忽略 、node_modules 依赖包、resources android与ios相关、src 主要的程序包、www为图片或者css或者js

2.config.xml 为工程配置文件,插件的版本等等类似pom.xml文件与web.xml的合体,为工程主要的配置文件

<content src="index.html" />定义首页
看一下index.html里面的内容<ion-app></ion-app> 为ionic的根,是app的开始如下注释:
<!-- Ionic's root component and where the app will load -->

系统会自动调用
app.module.ts 所有的ts,都要在该文件声明
IonicModule.forRoot(MyApp),这边设置开始的app为MyApp
然后看Myapp 在文件app.component.ts里面声明如下:
@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:any = TabsPage;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
    });
  }
}

展示界面app.html
内容
<ion-nav [root]="rootPage"></ion-nav> 看到了rootPage,
  rootPage:any = TabsPage;
则继续走了TabsPage.ts
@Component({
  templateUrl: 'tabs.html'
})
export class TabsPage {

  tab1Root = HomePage;
  tab2Root = AboutPage;
  tab3Root = ContactPage;

  constructor() {

  }
}
然后到界面tabs.html,内容如下:
<ion-tabs>
  <ion-tab [root]="tab1Root" tabTitle="Home" tabIcon="home"></ion-tab>
  <ion-tab [root]="tab2Root" tabTitle="About" tabIcon="information-circle"></ion-tab>
  <ion-tab [root]="tab3Root" tabTitle="Contact" tabIcon="contacts"></ion-tab>
</ion-tabs>
然后到about.ts、contact.ts、home.ts,然后看看about.html 、contact.html、home.html







  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值