angular-cn/aio/content/guide/browser-support.md

832 lines
14 KiB
Markdown
Raw Normal View History

# Browser support
2017-03-31 19:57:13 -04:00
Merge remote-tracking branch 'en/master' into aio # Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/architecture.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/cb-index.md # aio/content/guide/change-log.md # aio/content/guide/cheatsheet.md # aio/content/guide/cli-quickstart.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/dynamic-component-loader.md # aio/content/guide/dynamic-form.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/hierarchical-dependency-injection.md # aio/content/guide/i18n.md # aio/content/guide/index.md # aio/content/guide/learning-angular.md # aio/content/guide/lifecycle-hooks.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule.md # aio/content/guide/npm-packages.md # aio/content/guide/pipes.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/router.md # aio/content/guide/security.md # aio/content/guide/server-communication.md # aio/content/guide/set-document-title.md # aio/content/guide/setup-systemjs-anatomy.md # aio/content/guide/setup.md # aio/content/guide/structural-directives.md # aio/content/guide/styleguide.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/guide/ts-to-js.md # aio/content/guide/typescript-configuration.md # aio/content/guide/upgrade.md # aio/content/guide/user-input.md # aio/content/guide/visual-studio-2015.md # aio/content/guide/webpack.md # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/package.json # aio/src/styles/main.scss # aio/transforms/angular.io-package/index.js
2017-07-29 12:03:22 -04:00
# 浏览器支持
2017-03-31 19:57:13 -04:00
Angular supports most recent browsers. This includes the following specific versions:
Angular 支持大多数常用浏览器,包括下列版本:
<table>
<tr>
<th>
2018-03-03 08:06:01 -05:00
Browser
2018-03-03 08:06:01 -05:00
浏览器
</th>
<th>
2018-03-03 08:06:01 -05:00
Supported versions
2018-03-03 08:06:01 -05:00
支持的版本
</th>
</tr>
<tr>
<td>
2018-03-03 08:06:01 -05:00
Chrome
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
latest
2018-03-03 08:06:01 -05:00
最新版
</td>
2018-03-03 08:06:01 -05:00
</tr>
<tr>
<td>
2018-03-03 08:06:01 -05:00
Firefox
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
latest
2018-03-03 08:06:01 -05:00
最新版
</td>
2018-03-03 08:06:01 -05:00
</tr>
<tr>
<td>
2018-03-03 08:06:01 -05:00
Edge
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
2 most recent major versions
2018-03-03 08:06:01 -05:00
最近的两个主版本
</td>
2018-03-03 08:06:01 -05:00
</tr>
2018-03-03 08:06:01 -05:00
<tr>
2018-03-03 08:06:01 -05:00
<td>
2018-03-03 08:06:01 -05:00
IE
2018-03-03 08:06:01 -05:00
</td>
2018-03-03 08:06:01 -05:00
<td>
2018-03-03 08:06:01 -05:00
11<br>10<br>9
2018-03-03 08:06:01 -05:00
</td>
2018-03-03 08:06:01 -05:00
</tr>
2018-03-03 08:06:01 -05:00
<tr>
2018-03-03 08:06:01 -05:00
<tr>
2018-03-03 08:06:01 -05:00
<td>
2018-03-03 08:06:01 -05:00
IE Mobile
2018-03-03 08:06:01 -05:00
</td>
2018-03-03 08:06:01 -05:00
<td>
2018-03-03 08:06:01 -05:00
11
2018-03-03 08:06:01 -05:00
</td>
2018-03-03 08:06:01 -05:00
</tr>
2018-03-03 08:06:01 -05:00
<tr>
2018-03-03 08:06:01 -05:00
<td>
2018-03-03 08:06:01 -05:00
Safari
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
2 most recent major versions
2018-03-03 08:06:01 -05:00
最近的两个主版本
</td>
2018-03-03 08:06:01 -05:00
</tr>
2018-03-03 08:06:01 -05:00
<tr>
2018-03-03 08:06:01 -05:00
<td>
2018-03-03 08:06:01 -05:00
iOS
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
2 most recent major versions
2018-03-03 08:06:01 -05:00
最近的两个主版本
</td>
2018-03-03 08:06:01 -05:00
</tr>
2018-03-03 08:06:01 -05:00
<tr>
2018-03-03 08:06:01 -05:00
<td>
2018-03-03 08:06:01 -05:00
Android
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
Nougat (7.0)<br>Marshmallow (6.0)<br>Lollipop (5.0, 5.1)<br>KitKat (4.4)
2018-03-03 08:06:01 -05:00
</td>
2018-03-03 08:06:01 -05:00
</tr>
</table>
2017-04-10 11:51:13 -04:00
<div class="l-sub-section">
Angular's continuous integration process runs unit tests of the framework on all of these browsers for every pull request,
using <a href="https://saucelabs.com/">SauceLabs</a> and
<a href="https://www.browserstack.com">Browserstack</a>.
Angular 在持续集成过程中,对每一个提交都会使用 <a href="https://saucelabs.com/" target="_blank">SauceLabs</a>
<a href="https://www.browserstack.com" target="_blank">Browserstack</a> 在上述所有浏览器上执行单元测试。
2017-04-10 11:51:13 -04:00
</div>
## Polyfills
2017-03-31 19:57:13 -04:00
2018-02-28 00:17:39 -05:00
## 腻子脚本 (polyfill)
2017-03-31 19:57:13 -04:00
Angular is built on the latest standards of the web platform.
Targeting such a wide range of browsers is challenging because they do not support all features of modern browsers.
Angular 构建于 Web 平台的最新标准之上。
要支持这么多浏览器是一个不小的挑战,因为它们不支持现代浏览器的所有特性。
You compensate by loading polyfill scripts ("polyfills") for the browsers that you must support.
The [table below](#polyfill-libs) identifies most of the polyfills you might need.
2018-02-28 00:17:39 -05:00
我们可以通过加载腻子脚本("polyfills")来为想要支持的浏览器弥补这些特性。
[下表](#polyfill-libs) 列出了可能用到的大多数腻子脚本。
<div class="alert is-important">
The suggested polyfills are the ones that run full Angular applications.
You may need additional polyfills to support features not covered by this list.
Note that polyfills cannot magically transform an old, slow browser into a modern, fast one.
2018-02-28 00:17:39 -05:00
这些建议的腻子脚本是运行完整 Angular 应用所需的。
你可能还会需要另一些的腻子脚本来支持没有出现在此列表中的哪些特性。
注意,这些腻子脚本并没有神奇的魔力来把老旧、慢速的浏览器变成现代、快速的浏览器,它只是填充了 API。
</div>
2017-03-31 19:57:13 -04:00
## Enabling polyfills
2017-03-31 19:57:13 -04:00
2018-02-28 00:17:39 -05:00
## 启用腻子脚本
[Angular CLI](https://github.com/angular/angular-cli/wiki) users enable polyfills through the `src/polyfills.ts` file that
the CLI created with your project.
2018-02-28 00:17:39 -05:00
[Angular CLI](https://github.com/angular/angular-cli/wiki) 的用户可以通过自动创建的 `src/polyfills.ts` 文件来启用这些腻子脚本。
This file incorporates the mandatory and many of the optional polyfills as JavaScript `import` statements.
2018-02-28 00:17:39 -05:00
这个文件把强制的和很多可选的腻子脚本组织成 JavaScript 的 `import` 语句。
The npm packages for the _mandatory_ polyfills (such as `zone.js`) were installed automatically for you when you created your project and their corresponding `import` statements are ready to go. You probably won't touch these.
2018-02-28 00:17:39 -05:00
**强制性** 腻子脚本(如`zone.js`的npm 包在创建工程时就已经自动安装了,相应的 `import` 语句也都加好了。我们一般不用动它们。
2017-03-31 19:57:13 -04:00
But if you need an optional polyfill, you'll have to install its npm package.
For example, [if you need the web animations polyfill](http://caniuse.com/#feat=web-animation), you could install it with `npm`, using the following command (or the `yarn` equivalent):
2017-03-31 19:57:13 -04:00
2018-02-28 00:17:39 -05:00
但是如果要用一个可选的腻子脚本,就要通过 `npm``yarn` 来安装它们的 npm 包了。
比如,[如果你需要 web 动画的腻子脚本](http://caniuse.com/#feat=web-animation),就要通过下列命令之一来安装它:
<code-example language="sh" class="code-shell">
2018-03-03 08:06:01 -05:00
# note that the web-animations-js polyfill is only here as an example
# it isn't a strict requirement of Angular anymore (more below)
npm install --save web-animations-js
2018-03-03 08:06:01 -05:00
</code-example>
2017-03-31 19:57:13 -04:00
Then open the `polyfills.ts` file and un-comment the corresponding `import` statement as in the following example:
2017-03-31 19:57:13 -04:00
Merge remote-tracking branch 'en/master' into aio # Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/http.md # aio/content/guide/i18n.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule.md # aio/content/guide/npm-packages.md # aio/content/guide/pipes.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/structural-directives.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/marketing/index.html # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/src/app/embedded/api/api-list.component.ts # aio/src/app/layout/doc-viewer/doc-viewer.component.ts # aio/src/app/layout/footer/footer.component.html # aio/src/app/layout/toc/toc.component.html # aio/src/app/search/search.service.ts # aio/src/styles/1-layouts/_marketing-layout.scss # aio/yarn.lock
2018-02-27 19:08:59 -05:00
然后打开 `polyfills.ts` 文件,并反注释对应的 `import` 语句,就像这样:
<code-example title="src/polyfills.ts">
2018-03-03 08:06:01 -05:00
/**
* Required to support Web Animations `@angular/platform-browser/animations`.
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
**/
import 'web-animations-js'; // Run `npm install --save web-animations-js`.
2018-03-03 08:06:01 -05:00
</code-example>
If you can't find the polyfill you want in `polyfills.ts`,
add it yourself, following the same pattern:
2018-02-28 00:17:39 -05:00
如果在 `polyfills.ts` 中找不到要使用的腻子脚本,就可以仿照下列模式自行添加它:
Merge remote-tracking branch 'en/master' into aio # Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/http.md # aio/content/guide/i18n.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule.md # aio/content/guide/npm-packages.md # aio/content/guide/pipes.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/structural-directives.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/marketing/index.html # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/src/app/embedded/api/api-list.component.ts # aio/src/app/layout/doc-viewer/doc-viewer.component.ts # aio/src/app/layout/footer/footer.component.html # aio/src/app/layout/toc/toc.component.html # aio/src/app/search/search.service.ts # aio/src/styles/1-layouts/_marketing-layout.scss # aio/yarn.lock
2018-02-27 19:08:59 -05:00
1. install the npm package
Merge remote-tracking branch 'en/master' into aio # Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/http.md # aio/content/guide/i18n.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule.md # aio/content/guide/npm-packages.md # aio/content/guide/pipes.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/structural-directives.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/marketing/index.html # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/src/app/embedded/api/api-list.component.ts # aio/src/app/layout/doc-viewer/doc-viewer.component.ts # aio/src/app/layout/footer/footer.component.html # aio/src/app/layout/toc/toc.component.html # aio/src/app/search/search.service.ts # aio/src/styles/1-layouts/_marketing-layout.scss # aio/yarn.lock
2018-02-27 19:08:59 -05:00
安装 npm 包
2018-03-03 08:06:01 -05:00
1. `import` the file in `polyfills.ts`
Merge remote-tracking branch 'en/master' into aio # Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/http.md # aio/content/guide/i18n.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule.md # aio/content/guide/npm-packages.md # aio/content/guide/pipes.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/structural-directives.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/marketing/index.html # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/src/app/embedded/api/api-list.component.ts # aio/src/app/layout/doc-viewer/doc-viewer.component.ts # aio/src/app/layout/footer/footer.component.html # aio/src/app/layout/toc/toc.component.html # aio/src/app/search/search.service.ts # aio/src/styles/1-layouts/_marketing-layout.scss # aio/yarn.lock
2018-02-27 19:08:59 -05:00
`polyfills.ts``import` 这个文件
<div class="l-sub-section">
Non-CLI users should follow the instructions [below](#non-cli).
Merge remote-tracking branch 'en/master' into aio # Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/http.md # aio/content/guide/i18n.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule.md # aio/content/guide/npm-packages.md # aio/content/guide/pipes.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/structural-directives.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/marketing/index.html # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/src/app/embedded/api/api-list.component.ts # aio/src/app/layout/doc-viewer/doc-viewer.component.ts # aio/src/app/layout/footer/footer.component.html # aio/src/app/layout/toc/toc.component.html # aio/src/app/search/search.service.ts # aio/src/styles/1-layouts/_marketing-layout.scss # aio/yarn.lock
2018-02-27 19:08:59 -05:00
不使用 CLI 的用户可以遵循[下列](#non-cli)步骤自行操作。
2017-04-10 11:51:13 -04:00
</div>
{@a polyfill-libs}
2017-03-31 19:57:13 -04:00
### Mandatory polyfills
2017-03-31 19:57:13 -04:00
2018-02-28 00:17:39 -05:00
### 强制性腻子脚本
2017-03-31 19:57:13 -04:00
These are the polyfills required to run an Angular application on each supported browser:
2018-02-28 00:17:39 -05:00
下表中的腻子脚本是每个浏览器都要用到的:
<table>
<tr style="vertical-align: top">
<th>
2018-03-03 08:06:01 -05:00
Browsers (Desktop & Mobile)
浏览器(桌面和移动)
2017-08-06 01:37:25 -04:00
</th>
<th>
2018-03-03 08:06:01 -05:00
Polyfills Required
2017-08-06 01:37:25 -04:00
2018-03-03 08:06:01 -05:00
需要的腻子脚本
</th>
</tr>
<tr style="vertical-align: top">
<td>
2018-03-03 08:06:01 -05:00
Chrome, Firefox, Edge, Safari 9+
2018-03-03 08:06:01 -05:00
</td>
<td>
[ES7/reflect](guide/browser-support#core-es7-reflect) (JIT only)
</td>
</tr>
<tr style="vertical-align: top">
<td>
2018-03-03 08:06:01 -05:00
Safari 7 & 8, IE10 & 11, Android 4.1+
2018-03-03 08:06:01 -05:00
</td>
<td>
2017-03-31 19:57:13 -04:00
[ES6](guide/browser-support#core-es6)
</td>
</tr>
<tr style="vertical-align: top">
<td>
2018-03-03 08:06:01 -05:00
IE9
2018-03-03 08:06:01 -05:00
</td>
<td>
2017-03-31 19:57:13 -04:00
[ES6<br>classList](guide/browser-support#classlist)
</td>
</tr>
</table>
### Optional browser features to polyfill
2017-03-31 19:57:13 -04:00
2018-02-28 00:17:39 -05:00
### 可选浏览器特性的腻子脚本
2017-08-06 01:21:34 -04:00
Some features of Angular may require additional polyfills.
2018-02-28 00:17:39 -05:00
有些 Angular 特性可能需要额外的腻子脚本。
For example, the animations library relies on the standard web animation API, which is only available in Chrome and Firefox today.
(note that the dependency of web-animations-js in Angular is only necessary if `AnimationBuilder` is used.)
2018-02-28 00:17:39 -05:00
例如,动画库依赖于标准的 web 动画 API目前它只在 Chrome 和 Firefox 上可用。你可能需要一个腻子脚本来在其它浏览器上使用动画功能。
Here are the features which may require additional polyfills:
2018-02-28 00:17:39 -05:00
下列特性可能需要更多腻子脚本:
<table>
<tr style="vertical-align: top">
<th>
2018-03-03 08:06:01 -05:00
Feature
2018-03-03 08:06:01 -05:00
Merge remote-tracking branch 'en/master' into aio # Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/architecture.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/cb-index.md # aio/content/guide/change-log.md # aio/content/guide/cheatsheet.md # aio/content/guide/cli-quickstart.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/dynamic-component-loader.md # aio/content/guide/dynamic-form.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/hierarchical-dependency-injection.md # aio/content/guide/i18n.md # aio/content/guide/index.md # aio/content/guide/learning-angular.md # aio/content/guide/lifecycle-hooks.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule.md # aio/content/guide/npm-packages.md # aio/content/guide/pipes.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/router.md # aio/content/guide/security.md # aio/content/guide/server-communication.md # aio/content/guide/set-document-title.md # aio/content/guide/setup-systemjs-anatomy.md # aio/content/guide/setup.md # aio/content/guide/structural-directives.md # aio/content/guide/styleguide.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/guide/ts-to-js.md # aio/content/guide/typescript-configuration.md # aio/content/guide/upgrade.md # aio/content/guide/user-input.md # aio/content/guide/visual-studio-2015.md # aio/content/guide/webpack.md # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/package.json # aio/src/styles/main.scss # aio/transforms/angular.io-package/index.js
2017-07-29 12:03:22 -04:00
特性
2018-03-03 08:06:01 -05:00
</th>
<th>
2018-03-03 08:06:01 -05:00
Polyfill
2018-03-03 08:06:01 -05:00
2018-02-28 00:17:39 -05:00
腻子脚本
</th>
<th style="width: 50%">
2018-03-03 08:06:01 -05:00
Browsers (Desktop & Mobile)
浏览器(桌面和移动)
</th>
</tr>
<tr style="vertical-align: top">
<td>
[JIT compilation](guide/aot-compiler).
Required to reflect for metadata.
2018-03-03 08:06:01 -05:00
Merge remote-tracking branch 'en/master' into aio # Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/http.md # aio/content/guide/i18n.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule.md # aio/content/guide/npm-packages.md # aio/content/guide/pipes.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/structural-directives.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/marketing/index.html # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/src/app/embedded/api/api-list.component.ts # aio/src/app/layout/doc-viewer/doc-viewer.component.ts # aio/src/app/layout/footer/footer.component.html # aio/src/app/layout/toc/toc.component.html # aio/src/app/search/search.service.ts # aio/src/styles/1-layouts/_marketing-layout.scss # aio/yarn.lock
2018-02-27 19:08:59 -05:00
[JIT 编译](guide/aot-compiler) 需要 reflect 来提供元数据。
2018-03-03 08:06:01 -05:00
</td>
<td>
[ES7/reflect](guide/browser-support#core-es7-reflect)
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
All current browsers. Enabled by default.
Can remove if you always use AOT and only use Angular decorators.
2018-03-03 08:06:01 -05:00
Merge remote-tracking branch 'en/master' into aio # Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/http.md # aio/content/guide/i18n.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule.md # aio/content/guide/npm-packages.md # aio/content/guide/pipes.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/structural-directives.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/marketing/index.html # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/src/app/embedded/api/api-list.component.ts # aio/src/app/layout/doc-viewer/doc-viewer.component.ts # aio/src/app/layout/footer/footer.component.html # aio/src/app/layout/toc/toc.component.html # aio/src/app/search/search.service.ts # aio/src/styles/1-layouts/_marketing-layout.scss # aio/yarn.lock
2018-02-27 19:08:59 -05:00
默认对目前的所有浏览器都启用了。如果总是使用 AOT 模式,并且只使用 Angular 自带的装饰器,那么可以移除它。
2018-03-03 08:06:01 -05:00
</td>
</tr>
<tr style="vertical-align: top">
<td>
[Animations](guide/animations)
Merge remote-tracking branch 'en/master' into aio # Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/architecture.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/cb-index.md # aio/content/guide/change-log.md # aio/content/guide/cheatsheet.md # aio/content/guide/cli-quickstart.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/dynamic-component-loader.md # aio/content/guide/dynamic-form.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/hierarchical-dependency-injection.md # aio/content/guide/i18n.md # aio/content/guide/index.md # aio/content/guide/learning-angular.md # aio/content/guide/lifecycle-hooks.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule.md # aio/content/guide/npm-packages.md # aio/content/guide/pipes.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/router.md # aio/content/guide/security.md # aio/content/guide/server-communication.md # aio/content/guide/set-document-title.md # aio/content/guide/setup-systemjs-anatomy.md # aio/content/guide/setup.md # aio/content/guide/structural-directives.md # aio/content/guide/styleguide.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/guide/ts-to-js.md # aio/content/guide/typescript-configuration.md # aio/content/guide/upgrade.md # aio/content/guide/user-input.md # aio/content/guide/visual-studio-2015.md # aio/content/guide/webpack.md # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/package.json # aio/src/styles/main.scss # aio/transforms/angular.io-package/index.js
2017-07-29 12:03:22 -04:00
[动画](guide/animations)
<br>Only if `Animation Builder` is used within the application--standard
animation support in Angular doesn't require any polyfills (as of NG6).
2018-03-03 08:06:01 -05:00
2018-02-28 00:17:39 -05:00
<br>只有在应用中用到了 `Animation Builder` 时才需要Angular 标准的动画支持是不需要任何腻子脚本的(截至 NG6
</td>
<td>
2017-03-31 19:57:13 -04:00
[Web Animations](guide/browser-support#web-animations)
[Web 动画](guide/browser-support#web-animations)
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
<p>If AnimationBuilder is used then the polyfill will enable scrubbing
support for IE/Edge and Safari (Chrome and Firefox support this natively).</p>
2018-03-03 08:06:01 -05:00
2018-02-28 00:17:39 -05:00
<p>如果使用了AnimationBuilder那么腻子脚本将为 IE/Edge 和 Safari 启用擦除scrubbing支持Chrome 和 Firefox 原生支持此特性)</p>
2018-03-03 08:06:01 -05:00
</td>
</tr>
<tr style="vertical-align: top">
<td>
If you use the following deprecated i18n pipes:
如果你使用下列已废弃的i18n管道
2018-03-03 08:06:01 -05:00
[date](api/common/DeprecatedDatePipe),
2018-03-03 08:06:01 -05:00
[currency](api/common/DeprecatedCurrencyPipe),
2018-03-03 08:06:01 -05:00
[decimal](api/common/DeprecatedDecimalPipe),
[percent](api/common/DeprecatedPercentPipe)
2018-03-03 08:06:01 -05:00
</td>
<td>
2017-03-31 19:57:13 -04:00
[Intl API](guide/browser-support#intl)
</td>
<td>
2018-03-03 08:06:01 -05:00
All but Chrome, Firefox, Edge, IE11 and Safari 10
除了 Chrome、Firefox、Edge、IE11 和 Safari 10 外的所有浏览器
</td>
</tr>
<tr style="vertical-align: top">
<td>
2018-03-03 08:06:01 -05:00
[NgClass](api/common/NgClass)
on SVG elements
在 SVG 元素上应用时
</td>
<td>
2017-03-31 19:57:13 -04:00
[classList](guide/browser-support#classlist)
</td>
<td>
2018-03-03 08:06:01 -05:00
IE10, IE11
2018-03-03 08:06:01 -05:00
</td>
</tr>
<tr style="vertical-align: top">
<td>
2018-03-03 08:06:01 -05:00
[Http](guide/http)
when sending and receiving binary data
用 [Http](guide/http) 发送和接收二进制数据时
</td>
<td>
2017-03-31 19:57:13 -04:00
2018-03-03 08:06:01 -05:00
[Typed&nbsp;Array](guide/browser-support#typedarray)
<br>
[Blob](guide/browser-support#blob)
2018-03-03 08:06:01 -05:00
<br>
[FormData](guide/browser-support#formdata)
</td>
<td>
2018-03-03 08:06:01 -05:00
IE 9
2018-03-03 08:06:01 -05:00
</td>
</tr>
</table>
### Suggested polyfills ##
2018-02-28 00:17:39 -05:00
### 建议的腻子脚本 ##
Below are the polyfills which are used to test the framework itself. They are a good starting point for an application.
2018-02-28 00:17:39 -05:00
下表中是用来测试框架本身的腻子脚本,它们是应用程序的优质起点。
<table>
<tr>
<th>
2017-08-06 01:37:25 -04:00
2018-03-03 08:06:01 -05:00
Polyfill
2017-08-06 01:37:25 -04:00
2018-03-03 08:06:01 -05:00
腻子脚本
2017-08-06 01:37:25 -04:00
</th>
<th>
2018-03-03 08:06:01 -05:00
License
2018-03-03 08:06:01 -05:00
授权方式
</th>
<th>
2018-03-03 08:06:01 -05:00
Size*
2018-03-03 08:06:01 -05:00
大小*
</th>
</tr>
<tr>
<td>
<a id='core-es7-reflect' href="https://github.com/zloirock/core-js/blob/master/es7/reflect.js">ES7/reflect</a>
</td>
<td>
2018-03-03 08:06:01 -05:00
MIT
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
0.5KB
2018-03-03 08:06:01 -05:00
</td>
</tr>
<tr>
<td>
<a id='core-es6' href="https://github.com/zloirock/core-js">ES6</a>
</td>
<td>
2018-03-03 08:06:01 -05:00
MIT
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
27.4KB
2018-03-03 08:06:01 -05:00
</td>
</tr>
<tr>
<td>
<a id='classlist' href="https://github.com/eligrey/classList.js">classList</a>
</td>
<td>
2018-03-03 08:06:01 -05:00
Public domain
2018-03-03 08:06:01 -05:00
公共域
</td>
<td>
2018-03-03 08:06:01 -05:00
1KB
2018-03-03 08:06:01 -05:00
</td>
</tr>
<tr>
<td>
<a id='intl' href="https://github.com/andyearnshaw/Intl.js">Intl</a>
</td>
<td>
2018-03-03 08:06:01 -05:00
MIT / Unicode license
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
13.5KB
2018-03-03 08:06:01 -05:00
</td>
</tr>
<tr>
<td>
2018-03-03 08:06:01 -05:00
<a id='web-animations' href="https://github.com/web-animations/web-animations-js">Web Animations</a>
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
Apache
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
14.8KB
2018-03-03 08:06:01 -05:00
</td>
</tr>
<tr>
<td>
<a id='typedarray' href="https://github.com/inexorabletash/polyfill/blob/master/typedarray.js">Typed Array</a>
</td>
<td>
2018-03-03 08:06:01 -05:00
MIT
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
4KB
2018-03-03 08:06:01 -05:00
</td>
</tr>
<tr>
<td>
<a id='blob' href="https://github.com/eligrey/Blob.js">Blob</a>
</td>
<td>
2018-03-03 08:06:01 -05:00
MIT
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
1.3KB
2018-03-03 08:06:01 -05:00
</td>
</tr>
<tr>
<td>
<a id='formdata' href="https://github.com/francois2metz/html5-formdata">FormData</a>
</td>
<td>
2018-03-03 08:06:01 -05:00
MIT
2018-03-03 08:06:01 -05:00
</td>
<td>
2018-03-03 08:06:01 -05:00
0.4KB
2018-03-03 08:06:01 -05:00
</td>
</tr>
</table>
2018-03-03 08:06:01 -05:00
\* Figures are for minified and gzipped code,
computed with the <a href="http://closure-compiler.appspot.com/home">closure compiler</a>.
2017-08-06 01:37:25 -04:00
2018-03-03 08:06:01 -05:00
\* 这里的数据都按最小化并且 gzip 压缩后的版本算,是由<a href="http://closure-compiler.appspot.com/home">closure compiler</a>计算出的。
2017-08-06 01:21:34 -04:00
{@a non-cli}
2018-03-03 08:06:01 -05:00
## Polyfills for non-CLI users
2018-02-28 00:17:39 -05:00
## 不使用 CLI 的用户的腻子脚本
Merge remote-tracking branch 'en/master' into aio # Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/http.md # aio/content/guide/i18n.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule.md # aio/content/guide/npm-packages.md # aio/content/guide/pipes.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/structural-directives.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/marketing/index.html # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/src/app/embedded/api/api-list.component.ts # aio/src/app/layout/doc-viewer/doc-viewer.component.ts # aio/src/app/layout/footer/footer.component.html # aio/src/app/layout/toc/toc.component.html # aio/src/app/search/search.service.ts # aio/src/styles/1-layouts/_marketing-layout.scss # aio/yarn.lock
2018-02-27 19:08:59 -05:00
If you are not using the CLI, you should add your polyfill scripts directly to the host web page (`index.html`), perhaps like this.
2018-02-28 00:17:39 -05:00
如果你不使用 CLI就要直接把腻子脚本添加到宿主页`index.html`)中,就像这样:
Merge remote-tracking branch 'en/master' into aio # Conflicts: # aio/content/guide/ajs-quick-reference.md # aio/content/guide/animations.md # aio/content/guide/aot-compiler.md # aio/content/guide/attribute-directives.md # aio/content/guide/bootstrapping.md # aio/content/guide/browser-support.md # aio/content/guide/component-interaction.md # aio/content/guide/component-styles.md # aio/content/guide/dependency-injection-in-action.md # aio/content/guide/dependency-injection.md # aio/content/guide/deployment.md # aio/content/guide/displaying-data.md # aio/content/guide/form-validation.md # aio/content/guide/forms.md # aio/content/guide/glossary.md # aio/content/guide/http.md # aio/content/guide/i18n.md # aio/content/guide/ngmodule-faq.md # aio/content/guide/ngmodule.md # aio/content/guide/npm-packages.md # aio/content/guide/pipes.md # aio/content/guide/quickstart.md # aio/content/guide/reactive-forms.md # aio/content/guide/structural-directives.md # aio/content/guide/template-syntax.md # aio/content/guide/testing.md # aio/content/marketing/index.html # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt2.md # aio/content/tutorial/toh-pt3.md # aio/content/tutorial/toh-pt4.md # aio/content/tutorial/toh-pt5.md # aio/content/tutorial/toh-pt6.md # aio/src/app/embedded/api/api-list.component.ts # aio/src/app/layout/doc-viewer/doc-viewer.component.ts # aio/src/app/layout/footer/footer.component.html # aio/src/app/layout/toc/toc.component.html # aio/src/app/search/search.service.ts # aio/src/styles/1-layouts/_marketing-layout.scss # aio/yarn.lock
2018-02-27 19:08:59 -05:00
<code-example title="src/index.html">
2018-03-03 08:06:01 -05:00
&lt;!-- pre-zone polyfills -->
&lt;script src="node_modules/core-js/client/shim.min.js">&lt;/script>
&lt;script src="node_modules/web-animations-js/web-animations.min.js">&lt;/script>
&lt;script>
/**
2018-03-03 08:06:01 -05:00
* you can configure some zone flags which can disable zone interception for some
2018-03-03 08:06:01 -05:00
* asynchronous activities to improve startup performance - use these options only
2018-03-03 08:06:01 -05:00
* if you know what you are doing as it could result in hard to trace down bugs..
*/
// __Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
// __Zone_disable_on_property = true; // disable patch onProperty such as onclick
// __zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
/*
2018-03-03 08:06:01 -05:00
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
2018-03-03 08:06:01 -05:00
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*/
// __Zone_enable_cross_context_check = true;
&lt;/script>
&lt;!-- zone.js required by Angular -->
&lt;script src="node_modules/zone.js/dist/zone.js">&lt;/script>
&lt;!-- application polyfills -->
2018-03-03 08:06:01 -05:00
</code-example>
2018-03-03 08:06:01 -05:00