ionic2和angular的一些记录

1.Ionic2编译成APP后,启动出现 can not connect www....index.html
问题所在是index.html页面上引入某些css,js文件,需要internet加载,因此不能联网报错。解决方法是不要在index.html上加载其他因特网上的资源,或者异步加载。
解决方法如下:添加 <preference name="loadUrlTimeoutValue" value="60000" />到config.xml.或者通过主页转发:1.重命名index.html为main.html;
2.创建新的主页如下:<!doctype html>
<html>
  <head>
   <title>tittle</title>
   <script>
     window.location='./main.html';
   </script>
  <body>
  </body>
</html>
3.重新编译app

2.Ionic2组件之间的通讯
父子组件中,使用@input和@output通讯,@output则需要EventEmitter的方式,传递消息到父组件。在html中,使用[]表示绑定输入数据,()表示绑定输出数据。

3.Angular、typescript中编写回调函数,保存函数作用域的方式
问题在于,typescript中没有闭包以及bind函数的概念。解决方法:使用箭头表达式 ()=>{}, 锁定函数的作用域

4.Angular中html没有filter过滤器的概念
解决方法:使用typescript中class成员变量的get、set方法,达到过滤值的效果,或者使用angular2的pipe实现过滤器

5.Ionic2打包成APK后,设备不能访问网络的问题,如果一开始都可以访问,后来就不可以了。
解决方法:卸载Cordova插件cordova-plugin-whitelist,然后重新安装就行了

6.Ionic2 cordova的某些原生插件不能用,比如拍照、录像、挑选相册出问题
解决方法,在config.xml中添加<preference name="AndroidLaunchMode" value="standard"/>

7.ionc2 在真机上调试
首先,在cmd上输入 adb devices ,把手机挂载,然后输入ionic cordova run android --l --c,在手机上测试app并开启调试模式,也可以ionic serve  --address 192.168.xxx.xxx 指定地址,手机预览
持续更新..

猜你喜欢

转载自blog.csdn.net/amesteur/article/details/80279876