Angular 2自举选项-AOT与JIT [英] Angular 2 Bootstrapping Options - AOT vs JIT

查看:87
本文介绍了Angular 2自举选项-AOT与JIT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是从Angular 2开始.

Just kick started with Angular 2.

  1. angular 2中有哪些不同的Bootstrapping选项?

  1. What are the various Bootstrapping options in angular 2?

为什么当我进行更改并刷新index.html时才花费很少的时间来检索HTML标记?

Why is that when I make a change and refresh the index.html takes little time to retrieve the HTML markups?

它们之间的区别

推荐答案

有两个选项

  1. 动态引导

  1. Dynamic bootstrapping

  • 编译器使用了 JIT (及时).
  • 在浏览器中动态编译ts文件.
  • 这就是index.html花很少的时间来检索标记的原因.
  • main.ts包含以下

  • compiler used JIT (Just in Time).
  • dynamically compiles the ts files in the browser.
  • this is the reason the index.html takes little time to retrieve the markups.
  • main.ts contains the following

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule }              from './app.module';

platformBrowserDynamic().bootstrapModule(AppModule);

  1. 静态引导

  • 编译器使用了 AoT (提前).
  • ts文件被编译成js文件,然后呈现给浏览器.
  • 通过这种方式,在其中创建一组包含模块和工厂的js文件,方法是使它们轻量化.
  • 最常用于移动电话和旧版网络.
  • main.ts包含以下

  • compiler used AoT (Ahead of Time).
  • The ts files are compiled into js files and then rendered to the browser.
  • By this, a set of js files containing modules and factories are created there by making them light weight.
  • Mostly used in the case of mobiles and legacy networks.
  • main.ts contains the following

    import { platformBrowser } from '@angular/platform-browser';
    import { AppModuleNgFactory }              from '../aot/app/app.module.ngfactory';
    
    platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
    

  • 差异

    这篇关于Angular 2自举选项-AOT与JIT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆