Collapsible
按需展开或收起内容。
实时预览
正在加载预览…
参数配置
全部字段 7
CollapsibleOptions
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.Collapsible(c.Key("collapsible"), t, &s.Open, nui.CollapsibleOptions{Label: "Advanced settings", Disabled: false, KeepMounted: false}, func(t nui.Theme) { ui.Text(c, "The hidden section is now expanded.") })使用说明
点击标题展开或收起内容,比较 Disabled 与 KeepMounted。打开状态独立持久保存;保留挂载与保留业务数据是两件事,业务数据仍应由应用持有。
API 参考
Collapsible
源码func Collapsible(c *ui.Context, t Theme, open *bool, o CollapsibleOptions, content func(Theme)) ui.ElementCollapsibleOptions
源码type CollapsibleOptions struct {
Label string
Icon *ui.SVG
Disabled, KeepMounted bool
OnChange func(bool)
Decoration
}| 字段 | 类型 | 说明 |
|---|---|---|
Label | stringGo 零值: | 控件标签或可访问名称。 |
Icon | *ui.SVGGo 零值: | 组件使用的 SVG 图标。 |
Disabled | boolGo 零值: | 禁用组件及其交互。 |
KeepMounted | boolGo 零值: | 隐藏时保留内容及其控件状态。 |
OnChange | func(bool)Go 零值: | 值发生变化时通知应用的回调。 |
UI | StylesGo 零值: | 以部件名称为键覆盖外观和间距。 |
Style | func(Slot, ui.Element)Go 零值: | 同步配置当前构建的部件;不要保留 Element。 |