简体   繁体   English

为什么Ionic Ionic2平台准备工作需要很长时间?

[英]Why Ionic Ionic2 platform ready is taking very long time?

Why would ionic platform takes very long time to call ready function..?? 为什么离子平台需要很长时间才能调用就绪函数。

Please check, attached video link : https://youtu.be/AWncpv5rIgQ 请检查,附带的视频链接: https : //youtu.be/AWncpv5rIgQ

Please suggest solutions.. 请提出解决方案。

 this.platform.ready().then(() => { // Okay, so the platform is ready and our plugins are available. // Here you can do any higher level native things you might need. alert(1); if(this.splashScreen) { alert(2); setTimeout(() => { alert(3); this.splashScreen.hide(); }, 1000); } }); 

If you are running your app in development mode it takes some time to fire the platform.ready() event since it has assertions and various necessary framework checks turned on. 如果您在开发模式下运行应用程序,则将花费一些时间来触发platform.ready()事件,因为该事件具有断言并且已启用各种必要的框架检查。

Try running the app in production mode to speed up and optimize the start of your application 尝试在生产模式下运行该应用程序,以加快和优化应用程序的启动

If you're in an ionic 2 app, you can enable this by doing the following, 如果您使用的是ionic 2应用,则可以执行以下操作来启用它,

open src/app/main.ts 打开src / app / main.ts

Import enableProdMode from Angular 2 core 从Angular 2核心导入enableProdMode

import {enableProdMode} from '@angular/core';

import { AppModule } from './app.module';

Then call the enableProdMode() function before bootstraping your module 然后在引导模块之前调用enableProdMode()函数

enableProdMode();

platformBrowserDynamic().bootstrapModule(AppModule);

and now while running the app through cli try adding a flag like "--prod" 现在通过cli运行应用程序时,尝试添加“ --prod”之类的标志

ionic run android --prod

In ionic 3.x, you don't have to enable anything in the code. 在ionic 3.x中,您无需在代码中启用任何功能。 you can simply run it using the cli command, 您只需使用cli命令运行它,

ionic cordova run android --prod

check this documentation from angular.io angular.io检查此文档

Hope that helps 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM