全局展示操作反馈信息。
可提供成功、警告和错误等反馈信息。
顶部居中显示并自动消失,是一种不打断用户操作的轻量级提示方式。
如果要修改message的默认配置,你可以设置提供商NZ_MESSAGE_CONFIG
的值来修改。
(如:在你的模块的providers中加入 {{ '{' }} provide: NZ_MESSAGE_CONFIG, useValue: {{ '{' }} nzDuration: 3000 {{ '}' }} {{ '}' }}
,NZ_MESSAGE_CONFIG
可以从ng-zorro-antd
导入)
默认配置为
{{ '{' }} nzDuration : 1500, nzMaxStack : 7, nzPauseOnHover : true, nzAnimate : true {{ '}' }}
信息提醒反馈。
自定义时长 10s
,默认时长为 1.5s
。
包括成功、失败、警告。
进行全局 loading,异步自行移除。
参数 | 类型 | 默认值 | 说明 |
---|---|---|---|
nzDuration | Number | 0 | 持续时间,当设置为0时不消失(可用于NzNotificationService中) |
nzMaxStack | Number | 8 | 可展示的最大提示数量 |
nzPauseOnHover | Boolean | true | 鼠标移上时暂停倒计时(可用于NzNotificationService中) |
nzAnimate | Boolean | true | 开关动画效果(可用于NzNotificationService中) |
提示:以下options参数支持全局配置中的 nzDuration/nzAnimate/nzPauseOnHover
方法 | 参数 | 说明 |
---|---|---|
loading | (content: string, options?: Object) |
加载中 |
success | (content: string, options?: Object) |
成功消息 |
error | (content: string, options?: Object) |
失败消息 |
warning | (content: string, options?: Object) |
警告消息 |
info | (content: string, options?: Object) |
信息消息 |
create | (type: string, content: string, options?: Object) |
提供type属性,可传入'success'等选项 |
html | (html: string, options?: Object) |
可使用html代码来渲染内容 |
remove | (id?: string) |
移除特定id的消息,当id为空时,移除所有消息 |