Splitter
拖动分隔条调整两个面板的比例。
实时预览
正在加载预览…
参数配置
全部字段 8
SplitterOptions
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.Splitter(c.Key("split"), t, &s.Ratio, nui.SplitterOptions{Percent: true, Vertical: false, Disabled: false, Min: nui.Set(float32(15)), Max: nui.Set(float32(85))}, func() { ui.Text(c, "Files").Padding(16) }, func() { ui.Text(c, "Editor").Padding(16) }).Height(240)使用说明
拖动两个面板之间的分隔条,比较纵向排列。比例状态保存在视图外;此例使用百分比范围 15–85,避免某一面板被完全挤掉。
API 参考
Splitter
源码func Splitter(c *ui.Context, t Theme, value *float32, o SplitterOptions, first, second func()) ui.ElementSplitterOptions
源码type SplitterOptions struct {
Vertical, Percent, Disabled bool
Min, Max Optional[float32]
OnChange func(float32)
Decoration
}| 字段 | 类型 | 说明 |
|---|---|---|
Vertical | boolGo 零值: | 启用纵向排列。 |
Percent | boolGo 零值: | 使用百分比而不是绝对尺寸。 |
Disabled | boolGo 零值: | 禁用组件及其交互。 |
Min | Optional[float32]Go 零值: | 下界;Optional 可明确指定零。 |
Max | Optional[float32]Go 零值: | 上界或数量上限,具体含义依组件而定。 |
OnChange | func(float32)Go 零值: | 值发生变化时通知应用的回调。 |
UI | StylesGo 零值: | 以部件名称为键覆盖外观和间距。 |
Style | func(Slot, ui.Element)Go 零值: | 同步配置当前构建的部件;不要保留 Element。 |