GVKun编程网logo

angular – 减少离子2应用程序中的启动时间

11

关于angular–减少离子2应用程序中的启动时间的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于android–如何在设备上运行时加快Ionic2应用程序的启动时间、angular–删除

关于angular – 减少离子2应用程序中的启动时间的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于android – 如何在设备上运行时加快Ionic 2应用程序的启动时间、angular – 删除离子3应用程序中提供程序的循环依赖关系、angular – 装饰器@page,@ component和@app在离子2应用程序中意味着什么?、angular2 – 如何部署Angular 2应用程序开发的Typescript到生产?等相关知识的信息别忘了在本站进行查找喔。

本文目录一览:

angular – 减少离子2应用程序中的启动时间

angular – 减少离子2应用程序中的启动时间

我是ionic-2项目的新手.我只想知道如何减少应用程序的启动时间.因为在启动屏幕3秒后,它显示白屏并需要9秒才能启动.
尝试将它放在main.ts文件的第二行

从’@ angular / core’导入{enableProdMode};

然后在引导线之前

enableProdMode();

也在构建时使用–prod so ionic build android –prod

android – 如何在设备上运行时加快Ionic 2应用程序的启动时间

android – 如何在设备上运行时加快Ionic 2应用程序的启动时间

我目前正在做一个带有离子2 angular2和Typescript的应用程序.在启动我的应用程序的速度时,我有一个很大的问题.当我为dev或prod环境构建应用程序并将其安装在任何设备上时,需要花费大量时间来加载.

当我启动应用程序时,它显示一个长时间停留的白色屏幕,这真的很烦人,因为用户不会等待那么长时间.

我确实删除了splashscreen cordova插件,并在config.xml中将splashscreen延迟更改为0,但仍然需要花费很多时间才能加载.

在启动我的应用程序时,只会执行几个Get请求.
这是我目前的Config.xml

<widget id="com.ionicframework.comvltapp596066" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>com.vlt.app</name>
    <description>An awesome Ionic/Cordova app.</description>
    <author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
    <content src="index.html" />
    <access origin="*" />
    <allow-navigation href="http://ionic.local/*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="webviewbounce" value="false" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="disallowOverscroll" value="true" />
    <preference name="android-minSdkVersion" value="16" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="2" />
    <preference name="SplashShowOnlyFirstTime" value="true" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="0" />
    <platform name="android">
        <allow-intent href="market:*" />
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
        <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
        <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
        <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
        <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
        <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
        <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
        <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
        <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
        <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
        <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
        <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
        <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
        <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
    </platform>
    <engine name="android" spec="^6.2.3" />
    <engine name="browser" spec="^4.1.0" />
    <plugin name="cordova-plugin-console" spec="1.0.5" />
    <plugin name="cordova-plugin-device" spec="1.1.4" />
    <plugin name="cordova-plugin-googlemaps" spec="^1.4.0">
        <variable name="API_KEY_FOR_ANDROID" value="AIzaSyALRGE9KkSD9Qpng8XR7vUaVNj1teJGhw4" />
    </plugin>
    <plugin name="cordova-plugin-inappbrowser" spec="^1.7.1" />
    <plugin name="cordova-plugin-statusbar" spec="2.2.2" />
    <plugin name="cordova-plugin-whitelist" spec="1.3.1" />
    <plugin name="cordova-sqlite-storage" spec="^2.0.4" />
    <plugin name="ionic-plugin-keyboard" spec="~2.2.1" />
</widget>

请帮忙!

解决方法

根据经验,我会说在Ionic应用程序中启动时间没有显着改善,但是从我收集的在线文章中,您可以优化您的Ionic应用程序以启动和更快地工作.

>必要时,优先选择Ionicons
>检查并确保您的javascript文件移动到页面底部
>不要使用像JQuery这样的不必要的库.
>使用更少的页面或以其他方式学习重用页面.
> Ionic 3还引入了延迟加载,以避免在启动时加载所有组件.

查看this链接了解更多详情

angular – 删除离子3应用程序中提供程序的循环依赖关系

angular – 删除离子3应用程序中提供程序的循环依赖关系

我在离子3应用程序的其他提供商中包括提供商.但它给了我错误’找不到供应商’.我做了一些研究,发现它是由于循环依赖.如何克服离子3应用程序中的循环依赖?
Angular不允许引用另一个提供者,因为它可能导致循环依赖注入.我解决它的方法是从构造函数中删除类变量的声明,并使用来自angular core的Injector使用以下代码在超时中注入依赖:

因此,假设您要在提供商B中包含提供商A,

import { ProviderA } from '../provider-a/provider-a';

export class ProviderB {
  provider_a:any;
  constructor(public injector: Injector) {
    console.log('Hello ProviderB Provider');
    setTimeout(() => this.provider_a = injector.get(ProviderA));
  }
}

angular – 装饰器@page,@ component和@app在离子2应用程序中意味着什么?

angular – 装饰器@page,@ component和@app在离子2应用程序中意味着什么?

我见过@app和@page和@component似乎可以互换使用,我不知道有什么区别.

ionic2文档在这方面非常糟糕,因此离子2应用程序的这些装饰器之间的根本区别是什么?何时使用一个而不是另一个?

解决方法

@Page和@App是不推荐使用的装饰器,您必须只关注@Component

angular2使用一种名为ReflectMetadata的东西,基本上是装饰器为你的类添加一些重要的元数据

angular2 – 如何部署Angular 2应用程序开发的Typescript到生产?

angular2 – 如何部署Angular 2应用程序开发的Typescript到生产?

我是Angular 2的新手。我困惑于Angular 2如何在生产环境中工作。

>在生产服务器中运行Angular 2应用程序的先决条件是什么?
>是否可能在IIS服务器中部署应用程序或需要节点服务器?
>在开发机器中使用节点编译文件后,我们需要将.js和.ts部署到生产环境吗?

我使用JSPM使我的angular2项目生产准备。其他流行的工具,如JSPM包括webpack和browserfy。 JSPM将完成的重要任务之一是捆绑构成您的angular2项目的各个模块。我还将“selfExecutingBundle”标志设置为true,并让JSPM制作一个捆绑的js文件(例如myApp.bundled.js),并从那里我minify它(myApp.bundled.min.js)和这一个脚本引用用于index.html文件。
<html>

<head>
    <title>Hello Angular World</title>
</head>
<body>
<div>
    <my-app>Loading...</my-app>
</div>
    <script src="/js/myApp.bundle.min.js"></script>
</body>

</html>

这就是你需要的!

在将来,当HTTP / 2规范更常见时,可能不太需要捆绑基于模块的项目,但现在我认为需要捆绑。

没有对你的typescript文件的引用(因为它们已经在制作myApp.bundled.js的过程中被传递)。正如Zama所说,你可以在任何服务器上运行angular2(我使用IIS和工作正常)。

更新:自从Angular 2的最终版本,我已经切换到使用角度cli为建设生产。安装很容易(没有意大利面条的gulp任务),最后的包是超优化的(esp由于树摇晃)。我建议检查angular-cli设置,开发和构建您的ng2项目。

我们今天的关于angular – 减少离子2应用程序中的启动时间的分享就到这里,谢谢您的阅读,如果想了解更多关于android – 如何在设备上运行时加快Ionic 2应用程序的启动时间、angular – 删除离子3应用程序中提供程序的循环依赖关系、angular – 装饰器@page,@ component和@app在离子2应用程序中意味着什么?、angular2 – 如何部署Angular 2应用程序开发的Typescript到生产?的相关信息,可以在本站进行搜索。

本文标签: