Ionic开发中常见问题和解决方案记录

1npm按装包失败

更换源:npm config set registry https://registry.npm.taobao.org

或者使用cnpm

sudo npm install -g cnpm --registry=https://registry.npm.taobao.org

2.ionic真机调试

ionic run android --livereload -c -s

3.ionic run ios 报错

sudo npm install -g ios-deploy --unsafe-perm=true

4.跨域(这个问题在android上有,请求发不出去)

cordova plugin add cordova-plugin-whitelist

5.google跨域插件:

Access-Control-Allow-Origin

6.更改statusbar颜色

cordova plugin add cordova-plugin-statusbar

7.ionic生成图标资源

准备好icon.png 和splash.png

ionic resources

8.解决android tabs的布局调到底部,和iOS一致

$ionicConfigProvider.tabs.position('bottom');

9.android录制屏幕:

adb shell screenrecord /sdcard/video/littleQ.mp4 命令录制

问题:

Using this version of Cordova with older version of cordova-android is being deprecated. Consider upgrading to cordova-android@5.0.0 ro newer

删除platforms对应的平台,重新platform add [platform]

ionic build android : Unable to start the daemon process error

在用户文件夹中找到.gradle文件夹,新增gradle.properties文件,内容如下:

org.gradle.jvmargs=-Xmx512m 

ionic跨域问题,在接口端加上:

 response.setHeader("Access-Control-Allow-Origin", "*");  
 response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");    
 
问题:ion-scroll 在 ion-content 里不能上下滑动 的解决方案:
        $timeout(function () {
//return false; // <--- comment this to "fix" the problem
var sv = $ionicScrollDelegate.$getByHandle('horizontalScroll').getScrollView(); var container = sv.__container; var originaltouchStart = sv.touchStart;
var originalmouseDown = sv.mouseDown;
var originaltouchMove = sv.touchMove;
var originalmouseMove = sv.mouseMove; container.removeEventListener('touchstart', sv.touchStart);
container.removeEventListener('mousedown', sv.mouseDown);
document.removeEventListener('touchmove', sv.touchMove);
document.removeEventListener('mousemove', sv.mousemove); sv.touchStart = function (e) {
e.preventDefault = function () { }
if (originalmouseMove) {
originaltouchStart.apply(sv, [e]);
}
} sv.touchMove = function (e) {
e.preventDefault = function () { }
if (originalmouseMove) {
originaltouchMove.apply(sv, [e]);
}
} sv.mouseDown = function (e) {
e.preventDefault = function () { }
if (originalmouseMove) {
originalmouseDown.apply(sv, [e]);
}
} sv.mouseMove = function (e) {
e.preventDefault = function () { }
if (originalmouseMove) {
originalmouseMove.apply(sv, [e]);
}
} container.addEventListener("touchstart", sv.touchStart, false);
container.addEventListener("mousedown", sv.mouseDown, false);
document.addEventListener("touchmove", sv.touchMove, false);
document.addEventListener("mousemove", sv.mouseMove, false);
});
上一篇:ANDROID_MARS学习笔记_S05_005_方向传感器


下一篇:Ancoda 下的python多版本共存