为什么有角度的包装是分开的,为什么我们需要它们 [英] Why angular packages are separated and why we need them

查看:93
本文介绍了为什么有角度的包装是分开的,为什么我们需要它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始构建一个新的angular 2应用程序.我浏览了这些文章,并从github下载了一些免费的应用程序,它们都具有angular/comman软件包以及一些其他软件包.我安装了角度包,并在package.json文件中添加了"angular": "^1.6.5".我不确定是否可以拥有完整的软件包,那么为什么还要单独安装comman软件包?

I have started building a new angular 2 app. I have gone through the articles and downloaded some free apps from github, all of them have angular/comman package along with some other packages. I installed angular package and it added "angular": "^1.6.5" in package.json file. I am not sure if we can have full package then why we install comman package separately ?

当我检查了其他应用程序时,他们大多关注

When I checked other app then they mostly have following

"@angular/common": "2.0.1",
"@angular/compiler": "2.0.1",
"@angular/core": "2.0.1",
"@angular/forms": "2.0.1",
"@angular/http": "2.0.1",
"@angular/platform-browser": "2.0.1",
"@angular/platform-browser-dynamic": "2.0.1",
"@angular/router": "3.0.1",

它们都是角核的一部分吗?我在这里看不到有角度的包装.

are they all part of angular core ? I can not see angular package here.

有没有关于角度2包装的文章或指南?

Is there any article or guidelines for angular 2 packages ?

推荐答案

以下是每个软件包的简要说明:

Here is the brief description of each package:

  • @ angular/core-包含核心功能,例如装饰器,组件视图,更改检测等.
  • @ angular/compiler-包含Angular编译器.
  • @ angular/platform-b​​rowser-包含引导程序和使用DOM所需的特定于浏览器的代码.如果您在浏览器以外的平台上使用Angular,则可能不需要.
  • @ angular/platform-b​​rowser-dynamic-包含应用程序动态引导程序的实现.如果使用AOT,则不需要.
  • @angular/platform-browser - contains browser specific code required to bootstrap the application and work with the DOM. May not be required if you use Angular on the platform other than browser.
  • @angular/platform-browser-dynamic - contains implementations for the dynamic bootstrap of the application. Not required if you use AOT.
  • @ angular/common-包含常用指令和管道
  • @ angular/forms-包含表单实现
  • @ angular/http-包含http客户端实现
  • @ angular/router-包含路由器实现

之所以不将其全部打包到一个大的@angular软件包中,是因为您可能不需要运行时中的所有内容.您的应用程序可能不使用表格或ngFor之类的内置指令,或者可能不使用路由.为什么要将它们全部加载到浏览器中?

The reason for not packaging it all into one huge @angular package is because you may not need everything in your runtime. You application may not use forms, or built-in directives like ngFor, or may not use routing. Why load it all into the browser?

此外,有时需要第二组软件包,有时不取决于设置.在运行时始终唯一需要的是@angular/core.

Also, the second group of packages is sometimes required and sometimes not depending on the setup. The only thing that is always required in runtime is @angular/core.

另请参见官方文档.

这篇关于为什么有角度的包装是分开的,为什么我们需要它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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