Banner
在页面内展示可关闭的通知条。
实时预览
正在加载预览…
参数配置
全部字段 9
BannerOptions
Go 代码
Go
// Inside a view; c is *ui.Context, t is nui.Theme.
// Keep s (example state) outside the view. See the complete example.
nui.Banner(c.Key("banner"), t, &s.Open, nui.BannerOptions{Title: "An update is available", Description: "Review the new release notes.", Color: nui.ColorDefault})
nui.Button(c.Key("show"), t, "Show banner", nui.ButtonOptions{Variant: nui.Outline}).OnClick(func() { s.Open = true })使用说明
关闭通知条,再用 Show banner 重新显示。Banner 的可见状态由外部布尔值控制,适合在当前内容区域展示可关闭的消息。
API 参考
Banner
源码func Banner(c *ui.Context, t Theme, open *bool, o BannerOptions) ui.ElementBannerOptions
源码type BannerOptions struct {
Title, Description, CloseLabel string
Color Color
Icon *ui.SVG
Actions func(*ui.Context, Theme)
OnClose func()
Decoration
}| 字段 | 类型 | 说明 |
|---|---|---|
Title | stringGo 零值: | 标题文字。 |
Description | stringGo 零值: | 补充说明文字。 |
CloseLabel | stringGo 零值: | 关闭操作的可访问名称。 |
Color | ColorGo 零值: | 语义颜色;默认值继承主题或组件配色。 |
Icon | *ui.SVGGo 零值: | 组件使用的 SVG 图标。 |
Actions | func(*ui.Context, Theme)Go 零值: | 附加操作或操作区域构建函数。 |
OnClose | func()Go 零值: | 关闭组件时通知应用的回调。 |
UI | StylesGo 零值: | 以部件名称为键覆盖外观和间距。 |
Style | func(Slot, ui.Element)Go 零值: | 同步配置当前构建的部件;不要保留 Element。 |