Ant Design 全局 message API,用于显示临时轻提示。
MessageInstance 为 Ant Design message 接口,提供以下方法:
success(content: string | ConfigOptions, duration?: number): MessageTypeerror(content: string | ConfigOptions, duration?: number): MessageTypewarning(content: string | ConfigOptions, duration?: number): MessageTypeinfo(content: string | ConfigOptions, duration?: number): MessageTypeloading(content: string | ConfigOptions, duration?: number): MessageTypectx.message 是 Ant Design 全局 message API,用于在页面顶部中央显示临时轻提示。消息会在一定时间后自动关闭,也可由用户关闭。
与 ctx.notification 的区别:
ctx.message:顶部中央的临时轻提示,自动消失ctx.notification:右上角通知面板,可手动关闭或自动消失显示成功提示。
参数:
content(string | ConfigOptions):消息内容或配置对象duration(number,可选):自动关闭延迟(秒),默认 3 秒返回值:MessageType,可用于手动关闭该条消息
显示错误提示。
参数:同上。
显示警告提示。
参数:同上。
显示信息提示。
参数:同上。
显示加载提示。
参数:同上。
当 content 为对象时,支持以下配置: