ionic + angluar 开发app的总结(ionic)
接触app开发从年初以来大约有半年了,总结一下最近半年学习,了解的相关知识:
1.ionic: 官方地址:https://ionicframework.com
首先接触的是ionic相关的东西,先看了ionic相关的介绍 Ionic apps are created and developed primarily through the Ionic command line utility (the “CLI”), and use Cordova to build/deploy as a native app,然后是ionic 的ui component就是一些按钮,下拉框,滑动等的样式,接着看了ionic相关的API记几个重要的:
API:
NavController:视图控制
方法:这2个方法都返回promise
pop() 从堆中将最上层的组件移除
push(page,param,opts) 在堆最上层添加一个新的组件,page :component 可以用import的方式或用component的名称的字符串,param 参数,向弹出的页面传递的参数如{ name:'小明' } 然后在弹出的component用NavParams接收传递来的参数,opts:NavOptions 弹出页面的动画时间等参数设置
lifecycle events:page的生命周期事件
ionViewDidLoad |
void | Runs when the page has loaded. This event only happens once per page being created. If a page leaves but is cached, then this event will not fire again on a subsequent viewing. The ionViewDidLoad event is good place to put your setup code for the page. |
ionViewWillEnter |
void | Runs when the page is about to enter and become the active page. |
ionViewDidEnter |
void | Runs when the page has fully entered and is now the active page. This event will fire, whether it was the first load or a cached page. |
ionViewWillLeave |
void | Runs when the page is about to leave and no longer be the active page. |
ionViewDidLeave |
void | Runs when the page has finished leaving and is no longer the active page. |
ionViewWillUnload |
void | Runs when the page is about to be destroyed and have its elements removed. |
ionViewCanEnter |
boolean/Promise<void> | Runs before the view can enter. This can be used as a sort of "guard" in authenticated views where you need to check permissions before the view can enter |
ionViewCanLeave |
boolean/Promise<void> | Runs before the view can leave. This can be used as a sort of "guard" in authenticated views where you need to check permissions before the view can leave |
NavParams:接收参数 this.navParams.get('userParams');
Platform:平台,android,iso,cordova等的判断,当前页面的相关属性等
ModalController:添加覆盖物
let profileModal = this.modalCtrl.create(Profile, { userId: 8675309 });//创建覆盖物
profileModal.onDidDismiss(data => { console.log(data); });//覆盖物被destory时触发的方法,data为ViewController.dismiss()销毁当前view传递来的数据
profileModal.present();//覆盖物展示
方法:create(component, data, opts)参数同上面的push方法
ViewController:视图相关的,可以订阅component的active,destory等生命周期事件
方法:dismiss(data, role , navOptions)
native API:调用android,ios等的功能的api,如调用手机相机等。
实际就是使用cordova的插件实现用js代码调用java代码或objec-c等代码,cordova的文档地址:http://cordova.apache.org/docs/en/latest/
目前项目使用的插件有高德定位的插件:cordova-plugin-gaode-location ,极光推送:jpush-phonegap-plugin

浙公网安备 33010602011771号