# Conflicts: # aio/content/guide/angular-compiler-options.md # aio/content/guide/aot-metadata-errors.md # aio/content/guide/architecture-next-steps.md # aio/content/guide/architecture.md # aio/content/guide/browser-support.md # aio/content/guide/cli-builder.md # aio/content/guide/comparing-observables.md # aio/content/guide/dependency-injection-providers.md # aio/content/guide/deployment.md # aio/content/guide/deprecations.md # aio/content/guide/glossary.md # aio/content/guide/ivy.md # aio/content/guide/observables.md # aio/content/guide/router.md # aio/content/guide/static-query-migration.md # aio/content/guide/template-typecheck.md # aio/content/guide/transition-and-triggers.md # aio/content/guide/updating-to-version-9.md # aio/content/marketing/docs.md # aio/content/navigation.json # aio/content/tutorial/index.md # aio/content/tutorial/toh-pt1.md # aio/content/tutorial/toh-pt4.md # aio/package.json # aio/src/app/custom-elements/api/api-list.component.ts # aio/src/app/layout/footer/footer.component.html # aio/yarn.lock # packages/common/src/pipes/number_pipe.ts # packages/forms/src/directives/validators.ts # packages/forms/src/model.ts
12 KiB
Updating to Angular version 9
更新到 Angular 版本 9
This guide contains everything you need to know about updating to the next Angular version.
本指南包含关于更新到下一个 Angular 版本所需的全部知识。
Updating CLI Apps
更新 CLI 应用
For step-by-step instructions on how to update to the latest Angular release (and leverage our automated migration tools to do so), use the interactive update guide at update.angular.io.
有关如何更新到最新 Angular 版本的分步说明(并利用我们的自动迁移工具进行更新),请使用 update.angular.io 上的交互式更新指南。
If you're curious about the specific migrations being run by the CLI, see the automated migrations section for details on what code is changing and why.
如果您对 CLI 正在运行的某些迁移工作感到好奇,参见“自动迁移”部分以了解关于要更改哪些代码以及更改原因的详细信息。
Changes and Deprecations in Version 9
版本 9 中的更改和弃用
For information about Angular's deprecation and removal practices, see Angular Release Practices.
有关 Angular 弃用和移除实践的信息,参见 Angular 的发布实践 。
{@a breaking-changes}
New Breaking Changes
新的重大变化
-
Angular now compiles with Ivy by default. See the Ivy compatibility section.
Angular 现在默认使用 Ivy 进行编译。参见 Ivy 兼容性部分 。
-
CLI apps compile in AOT mode by default (which includes template type-checking). Users who only built with JIT before may see new type errors. See our template type-checking guide for more information and debugging tips.
CLI 应用程序默认情况下以 AOT 模式编译(包括模板类型检查)。以前仅使用 JIT 构建的用户可能会看到新的类型错误。有关更多信息和调试提示,请参见我们的模板类型检查指南 。
-
Typescript 3.4 and 3.5 are no longer supported. Please update to Typescript 3.7.
不再支持 TypeScript 3.4 和 3.5。请更新至 Typescript 3.6。
-
tslib
is now listed as a peer dependency rather than a direct dependency. If you are not using the CLI, you must manually installtslib
, usingyarn add tslib
ornpm install tslib --save
.tslib
现在被列为对等(peer)依赖,而不是直接依赖。如果不使用 CLI,则必须手动安装tslib
,使用yarn add tslib
或npm install tslib --save
。
{@a deprecations}
{@a 弃用}
New Deprecations
新的弃用
API | Replacement | Notes |
---|---|---|
API | 替代品 | 备注 |
entryComponents |
none | See entryComponents |
entryComponents |
无 | 参见 entryComponents |
CurrencyPipe - DEFAULT_CURRENCY_CODE |
{provide: DEFAULT_CURRENCY_CODE, useValue: 'USD'} |
From v11 the default code will be extracted from the locale data given by LOCAL_ID , rather than USD . |
CurrencyPipe - DEFAULT_CURRENCY_CODE |
{provide: DEFAULT_CURRENCY_CODE, useValue: 'USD'} |
从 v11 开始,默认代码将从由 LOCAL_ID 提供的语言环境数据中提取,而不再是固定值 USD 。 |
ANALYZE_FOR_ENTRY_COMPONENTS |
none | See ANALYZE_FOR_ENTRY_COMPONENTS |
ANALYZE_FOR_ENTRY_COMPONENTS |
无 | 见ANALYZE_FOR_ENTRY_COMPONENTS |
ModuleWithProviders without a generic |
ModuleWithProviders with a generic |
See ModuleWithProviders section |
不带泛型的 ModuleWithProviders |
带泛型的 ModuleWithProviders |
参见 ModuleWithProviders 部分 |
Undecorated base classes that use Angular features | Base classes with @Directive() decorator that use Angular features |
See undecorated base classes section |
使用 Angular 特性的不带装饰器的基类 | 具有 Angular 特性的带 @Directive() 装饰器的基类 |
请参见不带装饰器的基类部分 |
esm5 and fesm5 distribution in @angular/* npm packages |
esm2015 and fesm2015 entrypoints |
See esm5 and fesm5 |
@angular/* npm 软件包中的 esm5 和 fesm5 分发版 |
esm2015 和 fesm2015 入口点 |
参见 esm5 和 fesm5 |
TestBed.get |
TestBed.inject |
Same behavior, but type safe. |
TestBed.get |
TestBed.inject |
行为相同,但类型安全。 |
{@a removals}
New Removals of Deprecated APIs
新删除的已弃用 API
Package | API | Replacement | Notes | |
---|---|---|---|---|
包 | API | 替代品 | 备注 | |
@angular/core |
Renderer |
Renderer2 |
Migration guide. | |
@angular/core |
Renderer |
Renderer2 |
迁移指南 | |
@angular/core |
RootRenderer |
RendererFactory2 |
none | |
@angular/core |
RootRenderer |
RendererFactory2 |
无 | |
@angular/core |
RenderComponentType |
RendererType2 |
none | |
@angular/core |
RenderComponentType |
RendererType2 |
无 | |
@angular/core |
WtfScopeFn |
none | v8 | See Web Tracing Framework |
@angular/core |
WtfScopeFn |
无 | v8 | 参见 Web 跟踪框架 |
@angular/core |
wtfCreateScope |
none | v8 | See Web Tracing Framework |
@angular/core |
wtfCreateScope |
无 | v8 | 参见 Web 跟踪框架 |
@angular/core |
wtfStartTimeRange |
none | v8 | See Web Tracing Framework |
@angular/core |
wtfStartTimeRange |
无 | v8 | 参见 Web 跟踪框架 |
@angular/core |
wtfEndTimeRange |
none | v8 | See Web Tracing Framework |
@angular/core |
wtfEndTimeRange |
无 | v8 | 参见 Web 跟踪框架 |
@angular/core |
wtfLeave |
none | v8 | See Web Tracing Framework |
@angular/core |
wtfLeave |
无 | v8 | 参见 Web 跟踪框架 |
@angular/common |
DeprecatedI18NPipesModule |
CommonModule |
none | |
@angular/common |
DeprecatedI18NPipesModule |
CommonModule |
无 | |
@angular/common |
DeprecatedCurrencyPipe |
CurrencyPipe |
none | |
@angular/common |
DeprecatedCurrencyPipe |
CurrencyPipe |
无 | |
@angular/common |
DeprecatedDatePipe |
DatePipe |
none | |
@angular/common |
DeprecatedDatePipe |
DatePipe |
无 | |
@angular/common |
DeprecatedDecimalPipe |
DecimalPipe |
none | |
@angular/common |
DeprecatedDecimalPipe |
DecimalPipe |
无 | |
@angular/common |
DeprecatedPercentPipe |
PercentPipe |
none | |
@angular/common |
DeprecatedPercentPipe |
PercentPipe |
无 | |
@angular/forms |
NgFormSelectorWarning |
none | ||
@angular/forms |
NgFormSelectorWarning |
无 | ||
@angular/forms |
ngForm element selector |
ng-form element selector |
none | |
@angular/forms |
ngForm 元素选择器 |
ng-form 元素选择器 |
无 | |
@angular/service-worker |
versionedFiles |
files |
In the service worker configuration file ngsw-config.json , replace versionedFiles with files . See Service Worker Configuration. |
|
@angular/service-worker |
versionedFiles |
files |
在 Service Worker 配置文件 ngsw-config.json ,用 files 替换 versionedFiles 。参见 Service Worker 配置 。 |
{@a ivy}
Ivy features and compatibility
Ivy 的特性与兼容性
In Version 9, Angular Ivy is the default rendering engine. If you haven't heard of Ivy, you can read more about it in the Angular Ivy guide.
在版本 9 中,Angular Ivy 是默认渲染引擎。如果您还没有听说过 Ivy,则可以在 Angular Ivy 指南中阅读有关它的更多信息。
-
Among other features, Ivy introduces more comprehensive type-checking within templates. For details, see Template Type-checking.
除其他功能外,Ivy 在模板中引入了更全面的类型检查。有关详细信息,请参见模板类型检查 。
-
For general guidance on debugging and a list of minor changes associated with Ivy, see the Ivy compatibility guide.
关于调试的一般性指南以及与 Ivy 相关的较小更改的列表,请参见 Ivy 兼容性指南 。
-
For help with opting out of Ivy, see the instructions here.
有关选择性禁用 Ivy 的帮助,参见此处的说明。
{@a migrations}
Automated Migrations for Version 9
版本 9 的自动迁移
Read about the migrations the CLI handles for you automatically:
了解 CLI 自动为您处理的迁移: