博客

待解决问题记录

0

1.如何阻止ios上滑动换页

 

 

2.click按下后,不抬起,组织了其他拖动事件/click外是否有其他事件

原来文档里有,隐藏的太深了

https://ionicframework.com/docs/components/#gestures

mqtt broker项目集合

0

https://github.com/mqtt/mqtt.github.io/wiki/servers

使用ionic/cordova读取小米蓝牙体重秤数据

0

一开始使用nordic app调试,可以直接读出数据,天真的以为体重秤都是使用的标准格式,然后就搜出了阿里体重秤格式(http://gaic.alicdn.com/ztms/ble-protocol/%E9%98%BF%E9%87%8C%E5%B0%8F%E6%99%BA%E8%93%9D%E7%89%99%E9%80%9A%E8%AE%AF%E5%8D%8F%E8%AE%AE-%E4%BA%91%E7%AB%AF%E7%89%88%E7%A7%A4.pdf)

结果尝试了不行,又搜索,找到了小米的格式(https://github.com/oliexdev/openScale/wiki/Xiaomi-Bluetooth-Mi-Scale)

ionic3测试程序如下:


 

ionic Events通信

0

之前为了让组件间通信,根据修仙之路教程使用rxjs写了一个消息通信服务

https://segmentfault.com/a/1190000008959575

今天发现ionic自带有类似功能:

http://ionicframework.com/docs/api/util/Events/

cordova插件开发札记

0

原文:
Plugin Initialization and Lifetime
One instance of a plugin object is created for the life of each WebView. Plugins are not instantiated until they are first referenced by a call from JavaScript, unlesswith an onload name attribute is set to “true” in config.xml. For example,


如果不加,则插件只有在被首次调用时才会被实例化

ionic开发环境搭建

0

1.安装node,并修改源为淘宝镜像源
node下载地址:http://nodejs.cn/download/
安装完成后,使用如下命令修改为淘宝镜像:
npm config set registry https://registry.npm.taobao.org

2.全局安装ionic、cordova
npm install -g ionic cordova

3.新建项目
ionic start myApp tabs
模板项目是从gihub拉取的,有时候会失败或者速度很慢,解决办法有两个:
1.番羽土啬
2.直接从github下载
tabs:https://github.com/ionic-team/ionic-starter-tabs
blank:https://github.com/ionic-team/ionic-starter-blank

4.运行项目
ionic serve

5.添加android平台
ionic cordova platform add android
检查环境
cordova requirements
如果提示:
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
cmd: Command failed with exit code 1 Error output:
‘avdmanager’ �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
Gradle: installed C:\gradle-3.3\bin\gradle
说明已经安装好了,Android target不用管

6.安装android相关环境
android sdk(这个得番羽土啬)
jdk
gradle

7.编译打包app
ionic cordova build android

————————————————————
ios打包从6开始不一样(待写)
6.添加ios平台
ionic cordova platform add ios
7.安装xcode
8.生成xcode项目,并使用xcode打开
ionic cordova build ios
9.选择证书,并编译

关于Visual studio code/power shell中无法使用virtualenv

0

Visual studio code使用power shell作为命令行工具,但在其中使用virtualenv的Scripts\activate.bat 无法进入到虚拟环境。
查了下,在power shell下应该使用ps脚本,virtualenv自带的有Scripts\activate.ps1
运行后power shell报错:

———————————————————————————————-
c:\Users\coloz\Desktop\servertest\iot\Scripts\activate.ps1 : 无法加载文件 C:\Users\coloz\Desktop\servertest\iot\Scripts\activate.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中
的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ c:\Users\coloz\Desktop\servertest\iot\Scripts\activate.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

———————————————————————————————-

报错中其实已经有解决办法https:/go.microsoft.com/fwlink/?LinkID=135170
简而言之,就是为了安全起见,power shell不能运行脚本,运行以下命令即可开启脚本运行权限:


 

js拖拽库

0

https://github.com/desandro/draggabilly
https://draggabilly.desandro.com/

https://github.com/taye/interact.js
http://interactjs.io/

ionic生命周期事件

0

angular有一套生命周期事件:

https://angular.cn/guide/lifecycle-hooks

ionic也有,其更贴近app交互需求,在开发时应尽量使用ionic这套:

Page Event Returns Description
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. TheionViewDidLoad 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

ionic/cordova插件开发

0

官方示例
https://github.com/apache/cordova-plugin-device