Ionic開發中常見問題和解決方案記錄

1npm按裝包失敗android

更換源:npm config set registry https://registry.npm.taobao.orgios

或者使用cnpmshell

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

 

2.ionic真機調試跨域

ionic run android --livereload -c -sapp

 

3.ionic run ios 報錯jvm

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

 

 

4.跨域(這個問題在android上有,請求發不出去)ide

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);
        });
View Code
相關文章
相關標籤/搜索