Intro
Welcome to the 9.0.0
version of ng-zorro-antd
,some APIs were deprecated in version 8.x, and warning message was given under dev mode. All deprecated APIs is removed in 9.0.0, if you have fixed all warnings in the 8.x version, you can follow these steps to upgrade your version.
Before upgrade
- Make sure
Node.js
>=10.13
- Create a new branch, or use other methods to back up the current project
- delete the package-lock.json file
Upgrade dependencies
- Upgrade Angular to 9.x version, ref https://update.angular.io/
- Run
ng update @angular/cdk
, if you have used@angular/cdk
. - if you have used
date-fns
in your project, upgrade it to2.x
version, ref https://github.com/date-fns/date-fns-upgrade. - if you have used
monaco-editor
please upgrade it to0.2.x
, don't forget to upgrademonaco-editor-webpack-plugin
to1.9.x
if you have used it.
Upgrade NG-ZORRO
- Run
ng update ng-zorro-antd
- If a warning message appears in the console, follow the prompts to modify the corresponding code
date-fns update
We have upgraded date-fns
to v2. When you switch to date-fns
, some date formats will have a breaking change. Such as:
<!-- datefns v1 -->
<nz-date-picker nzFormat="YYYY-MM-DD"></nz-date-picker>
<!-- datefns v2 -->
<nz-date-picker nzFormat="yyyy-MM-dd"></nz-date-picker>
We recommend using date-fns
v2 date format. If you don't want to use the new date format, you can use NZ_DATE_FNS_COMPATIBLE
. When set to true
, ng-zorro-antd
will convert the format of v1 to v2. See the comparison of the old and new formats here.
providers: [
{ provide: NZ_DATE_FNS_COMPATIBLE, useValue: true }
]
Note: NZ_DATE_FNS_COMPATIBLE
won't be kept for too long, we will remove the support for date-fns
v1 format until ng-zorro-antd
v10, we hope you can update the date-fns
date format in time. For date-fns
upgrade guide, see here.
Angular Ivy Supported
We have upgraded the @angular/*
and @angular/cdk
versions to v9, and now you can use the Ivy rendering engine to run your project, and enable the strictTemplates
option to use more strict template type checking.
More help go to Angular Ivy and Template type checking.
Ant Design 4 Spec
We have synced the Ant Design 4 design specification and support the Dark and Compact themes.
Enhanced Performance and Usability
- In previous versions, the Table component has integrated virtual scrolling, also now supported for Select and Tree components.
- Form and Table simplify usage and now allow for writing fewer templates and configurations.
- Allow adding icons in sub-modules to reduce the first screen load time.
- Now, the pop-up menu is automatically closed when the route is changed, and corresponding options have been added for components such as Modal.
Features
- breadcrumb: support indenpendent separator (#4713) (1f490e9)
- collapse: support nzExpandIconPosition (#4781) (760512a)
- grid: support nzFlex and nzGutter array, deprecated nzType (c4d2694)
- icon: support add icon in feat modules (#4711) (0bcd2a9)
- input: support textarea with clear icon (0af9242), closes #4623
- page-header: add
nzGhost
property (#4306) (4c78cca), closes #4303 - select: refactor the select to support virutal scroll (40daee9), closes #4585 #3497
- skeleton: add nz-skeleton-element (#4859) (8dc2ff3)
- tabs: add nzCanDeactivate hook (#4476) (a533980), closes #4432
- tag: support status colors (#4628) (aa22c0f), closes #4622 #4413
- tree-select: support
nzDropdownClassName
property (#4552) (df8c125), closes #4508 - typography: support
nzSuffix
property (#4629) (ca02a07), closes #4620 - space: add new component (#4928) (df01bd1), closes #4913
- table: support new nzQueryParams (#4970) (79ea999)
- tree: support virtual scroll (#4979) (6803a92), closes #4426 #3808 #3436 #2680 #1771
- form:
- date-picker:
- i18n:
- input-number:
- menu:
- code-editor:
- notification:
- pagination:
- progress:
- tooltip,etc:
Bug Fixes
- slider: fix handle transform in vertical mode (#4939) (6fba78d)
- badge: allow
nzTitle
set to null (#4965) (a35fb5e), closes #4776 - list: fix the avatar part old API (#4952) (d8a2594), closes #4912
- grid: fix grid responsive bug (#4906) (d6828ed)
- breadcrumb: fix breadcrumb link style (#4880) (2553328)
- button: fix button animation bug caused by angular (9e0df2a), closes #2697
- cascader: fix not showing empty when there's no options (#4565) (9d8d7e6), closes #4562
- mention: unable to select on mobile device (#4309) (1be6d51), closes #4281
- menu: fix menu overflow detection & replace ul with div (4c8032b), closes #3412 #4227 #3687
- pagination: replace full-width character with half-width (#4371) (cc3868e)
- timeline: fix reverse bug (#4690) (09bf8f4), closes #4509
- transfer: fix transfer nzTargetKeys property (#4670) (31089a1), closes #4641 #4360 #4210
- carousel: remove vertical api (#4376) (37aa921)
- icon: remove old api (#4375) (91e52ab)
- date-picker:
- modal:
- page-header:
- table:
- fix 4.1.0 style error (#4953) (44f606c)
- fix table no data (#4947) (7f7989e)
nzFilters
can is not null (#4595) (2c26e9f)- fix table data type (#4608) (70b1440), closes #4593
- fix table nzWidth bug without the first column (#4329) (c6bdf15), closes #4312
- support nzWidthConfig null undefined value (#4342) (761e8e0)
- fix nzTotal in frontend pagination false (#4922) (9ddc060), closes #4919
- time-picker:
- tree:
- empty:
- select:
- auto-complete:
- calendar:
- code-editor:
- drawer:
- dropdown:
- layout:
- message,notification:
- tooltip,popover,popconfirm:
- tree-select:
Performance Improvements
- checkbox: use css empty selector instead of observeContent (#4761) (da8821a)
- input: improve input-group perf (7af643b), closes #3950
- radio: refactor radio group data flow (#4770) (423a382)
BREAKING CHANGES
Note: All break changes are warned in the latest version of 8.x, if you have fixed all warnings in 8.x, there will no break changes for you.
- form:
nz-form-extra
is removed. Please usenzExtra
isnz-form-control
instead.nz-form-explain
is removed. Please usenzSuccessTip | nzWarningTip | nzErrorTip | nzValidatingTip
isnz-form-control
instead.
- input-number:
- ngModelChange trigger at once when user typing
- pagination:
- prev_5 and next_5 is needed when use nzItemRender
- 'pre' typo was corrected to 'prev'
- tree, tree-select:
- Removed
[nzDefaultExpandAll]
use[nzExpandAll]
instead. - Removed
[nzDefaultExpandedKeys]
use[nzExpandedKeys]
instead. - Removed
[nzDefaultSelectedKeys]
use[nzSelectedKeys]
instead. - Removed
[nzDefaultCheckedKeys]
use[nzCheckedKeys]
instead. - Removed
(nzOnSearchNode)
use(nzSearchValueChange)
instead. - Removed
[nzDefaultExpandedKeys]
use[nzExpandedKeys]
instead.
- Removed
- message,notification:
NZ_MESSAGE_CONFIG
is removed. Please useNzConfigService
instead.NZ_NOTIFICATION_CONFIG
is removed. Please useNzConfigService
instead.config
method ofNzMessageService
andNzNotificationService
is removed. Please useset
method ofNzConfigService
instead.
- empty:
NZ_DEFAULT_EMPTY_CONTENT
is removed. Please useNzConfigService
instead.
- carousel:
nzVertical
is removed. Please use 'nzDotPosition' instead.
- icon:
NZ_ICON_DEFAULT_TWOTONE_COLOR
is removed. UseNzConfigService
instead.i[nz-icon]
:twoToneColor
theme
spin
iconfont
type
inputs has been removed, usenzTwoToneColor
nzTheme
nzSpin
nzIconfont
nzType
instead.i.anticon
selector has been removed, usei[nz-icon]
instead.
- calendar:
<nz-calendar>
nzCard
input has been removed, usenzFullscreen
instead.
- tooltip,popover,popconfirm:
<nz-tooltip>
<nz-popover>
<nz-popconfirm>
components has been removed, use its directives instead.
- Removed deprecated API
NgZorroAntdModule.forRoot()
版本介绍
欢迎来到 ng-zorro-antd
的 9.0.0
版本,升级到最新版本之后,开发者不仅可以享受到最新版本 Angular 的支持,还可以获得最新特性和更好的性能。
ng-zorro-antd 的部分 API 在 8.x 版本进入弃用状态,并且在开发环境中给出了警告提醒,所有之前弃用 API 在 9.0.0 不再支持,如果你之前已经根据告警信息修改了对应组件的使用方式,那么 9.0.0 版本升级不会有任何障碍,请按照以下步骤进行。
开始升级之前
- 首先确保你
Node.js
>=10.13
- 创建新的分支,或者使用其他方式备份当前项目
- 删除项目下 package-lock.json 文件
升级相关依赖
- 升级 Angular 主版本号至 9.0.0 版本,可以参考 https://update.angular.io/
- 如果你有单独使用
@angular/cdk
请执行ng update @angular/cdk
- 如果你有单独使用
date-fns
请先升级到2.x
,升级指南 - 如果你有使用
monaco-editor
请先升级到0.2.x
, 使用monaco-editor-webpack-plugin
时请将其升级到1.9.x
升级 NG-ZORRO
- 运行
ng update ng-zorro-antd
- 如果控制台出现警告消息请按提示修改对应代码
date-fns 升级指南
当你切换至 date-fns
时,一些日期格式会有 breaking change。比如:
<!-- datefns v1 -->
<nz-date-picker nzFormat="YYYY-MM-DD"></nz-date-picker>
<!-- datefns v2 -->
<nz-date-picker nzFormat="yyyy-MM-dd"></nz-date-picker>
我们推荐使用 date-fns
v2 的日期格式。如果你不想使用新日期格式,你可以用 NZ_DATE_FNS_COMPATIBLE
,当设置为 true
时,ng-zorro-antd
会把 v1 的格式转为 v2,新旧格式的对比看这里。
providers: [
{ provide: NZ_DATE_FNS_COMPATIBLE, useValue: true }
]
但 NZ_DATE_FNS_COMPATIBLE
不会保留太久,到 ng-zorro-antd
v10 将会移除对 date-fns
v1 日期格式的支持,希望你能及时更新 date-fns
日期格式。关于 date-fns
升级指南看这里,如果业务中使用了 date-fns,可以参考 date-fns 官方兼容工具 查看。
新版本特性
支持 Angular Ivy
我们已经将 @angular/*
和 @angular/cdk
版本升级到 v9
,现在你可以使用 Ivy 渲染引擎运行你的项目,并且开启 strictTemplates
选项使用更严格的的模版类型检查。
获取更多帮助请前往 Angular Ivy 和 Template type 查看。
Ant Design 4 设计规范
我们已经同步了 Ant Design 4 设计规范,并且添加了暗黑(Dark)和紧凑(Compact) 主题支持。
性能和易用性增强
- 在之前的版本中 Table 组件已经集成了虚拟滚动,现在 Select 和 Tree 也同样支持;
- Form 和 Table 简化了使用方式,现在可以编写更少的模版和配置;
- 允许在子模块中添加图标,以减少首屏加载时间;
- 现在当路由改变时弹出菜单将自动关闭,同时为 Modal 等组件添加了对应选项;
Features
- breadcrumb: 支持独立 separator (#4713) (1f490e9)
- collapse: 支持 nzExpandIconPosition (#4781) ([760512a](760* 512a))
- grid: 支持 nzFlex 与 nzGutter 数组输入 (c4d2694)*
- icon: 支持在 feature module 中导入 icons (#4711) (* 0bcd2a9)
- input: 支持 textarea 带 clear 图标的效果 (0af9242), closes [#4623](https://github.com/NG-ZORRO/ng-zorro-antd/issues/* 4623)
- page-header: 增加
nzGhost
选项 (#4306) (4c78cca), closes #43* 03 - select: select 支持 virutal scroll 模式 (40daee9), closes #4585 [#3497](https://github.com/NG-ZORRO/ng-zorro-antd/issues/* 3497)
- skeleton: 增加 nz-skeleton-element (#4859) (8dc2ff3)*
- space: 添加新组件 (#4928) (df01bd1), closes [#4913](h* ttps://github.com//issues/4913)
- table: 支持
nzQueryParams
(#4970) (79ea999)* - tabs: 增加了 nzCanDeactivate 钩子 (#4476) ([a533980](a533* 980)), closes #4432
- tag: 增加 status colors 选项 (#4628) (aa22c0f), closes #4622 #44* 13
- tree: 支持虚拟滚动 (#4979) (6803a92), closes #4426 #3808 [#3436](ht* tps://github.com//issues/3436) #2680 #1771
- tree-select: 支持
nzDropdownClassName
选项 (#4552) (df8c125), closes #4508* - typography: 支持
nzSuffix
选项 (#4629) (ca02a07), closes #4620* - form:
- code-editor:
- date-picker:
- i18n:
- input-number:
- menu:
- notification:
- pagination:
- progress:
- tooltip:
Bug Fixes
- mention: 修复移动端选择问题 (#4309) (1be6d51), closes #4281
- menu: 修复在屏幕越界时的显示问题 (4c8032b), closes #3412 #4227 #3687
- message: 修复 prod 下 message 与 notification 的问题 (#4884) (3e2f85d)*
- page-header: 修复
location
注入问题 (#5013) (9073fa5), closes #4945* - pagination: 修复半角字符问题 (#4371) (cc3868e)*
- transfer: 修复 nzTargetKeys 无效问题 (#4670) ([31089a1](3* 1089a1)), closes #4641 #4360 #4210
- empty: 修复 Empty 在 dark 模式下的显示问题 (#4924) (bae59d7), closes #4921*
- grid: 修复响应式的问题 (#4906) (d6828ed)*
- list: 修复头像部分的兼容 API (#4952) ([d8a2594](d8a* 2594)), closes #4912
- badge: 允许将
nzTitle
设置为null
(#4965) (a35fb5e), closes [#4776](https://github.com/NG-ZORRO/ng-zorro-antd/is* sues/4776) - breadcrumb: 修复面包屑显示问题 (#4880) (2553328)*
- button: 修复 transition 显示问题 (9e0df2a), closes [#2697](https://github.com/NG-ZORRO/ng-zorro-antd/iss* ues/2697)
- cascader: 修复无选项时的显示问题 (#4565) (9d8d7e6), closes* #4562
- slider: 修复垂直模式下拖拽句柄样式问题 (#4939) (6fba78d)*
- timeline: 修复 reverse 下的展示问题 (#4690) (09bf8f4),* closes #4509
- auto-complete:
- code-editor:
- date-picker:
- drawer:
- dropdown:
- layout:
- modal:
- select:
- table:
- time-picker:
- tooltip:
- tree:
- tree-select:
Performance Improvements
- checkbox: 使用 css empty selector 代替了 observeContent (#4761) (da8821a)
- input: 提升 input 性能 (7af643b), closes #3950*
- radio: 重构了数据流 (#4770) (423a382)*
BREAKING CHANGES
注意: 所有不兼容改动均在 8.x 最新版本中给出了 warning,如果你在 8.x 最新版本中修复了所有 warning,9.x 可以直接升级的。
- calendar:
<nz-calendar>
nzCard
被移除了, 请使用nzFullscreen
代替。
- carousel:
nzVertical
被移除,请使用 'nzDotPosition' 代替。
- empty:
NZ_DEFAULT_EMPTY_CONTENT
被移除,请使用NzConfigService
代替。
- form:
nz-form-extra
被移除,请使用nz-form-control
中的nzExtra
代替。nz-form-explain
被移除,请使用nz-form-control
中的nzSuccessTip | nzWarningTip | nzErrorTip | nzValidatingTip
代替。
- icon:
i[nz-icon]
:twoToneColor
theme
spin
iconfont
type
输入被移除, 请使用nzTwoToneColor
nzTheme
nzSpin
nzIconfont
nzType
代替。i.anticon
被移除, 请使用i[nz-icon]
代替。NZ_ICON_DEFAULT_TWOTONE_COLOR
被移除, 请使用NzConfigService
。
- input-number:
- ngModelChange 会在用户输入时立刻触发
- message,notification:
NZ_MESSAGE_CONFIG
被移除,请使用NzConfigService
代替。NZ_NOTIFICATION_CONFIG
被移除,请使用NzConfigService
代替。config
method ofNzMessageService
andNzNotificationService
被移除,请使用set
method ofNzConfigService
代替。- 用
NzMessageRef
替换NzMessageDataFilled
- 用
NzNotificationRef
替换NzNotificationDataFilled
- pagination:
- 当定制 nzItemRender 时,需要考虑 prev_5 and next_5
- 'pre' 被修改为 'prev'
- tree, tree-select:
- 移除了
[nzDefaultExpandAll]
请使用[nzExpandAll]
代替。 - 移除了
[nzDefaultExpandedKeys]
请使用[nzExpandedKeys]
代替。 - 移除了
[nzDefaultSelectedKeys]
请使用[nzSelectedKeys]
代替。 - 移除了
[nzDefaultCheckedKeys]
请使用[nzCheckedKeys]
代替。 - 移除了
(nzOnSearchNode)
请使用(nzSearchValueChange)
代替。
- 移除了
- tooltip,popover,popconfirm:
<nz-tooltip>
<nz-popover>
<nz-popconfirm>
组件被移除, 请使用对应的 directives 代替。
- 移除 API:
NgZorroAntdModule.forRoot()