Tree
浏览带有稳定标识的层级数据。
实时预览
正在加载预览…
参数配置
全部字段 9
TreeOptions
TreeNodeItems
列表项 · 2
TreeNode
TreeNode
列表项 · 1
TreeNode
列表项 · 0
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.Tree(c.Key("tree"), t, &s.Tree, nui.TreeOptions{Label: "Project files", Height: 260, Disabled: false})使用说明
展开文件夹并选择项目,使用键盘查看层级导航。TreeState 在初始化时装入示例节点;真实文件树应在操作或后台任务完成后更新数据。
API 参考
Tree
源码func Tree(c *ui.Context, t Theme, s *TreeState, o TreeOptions) ui.ElementTreeOptions
源码type TreeOptions struct {
Label, EmptyText string
Height float32
Disabled bool
OnChange func()
OnLoad func(string, TreeTicket)
Decoration
}| 字段 | 类型 | 说明 |
|---|---|---|
Label | stringGo 零值: | 控件标签或可访问名称。 |
EmptyText | stringGo 零值: | 没有可显示数据时的文案。 |
Height | float32Go 零值: | 高度,单位为 DIP。 |
Disabled | boolGo 零值: | 禁用组件及其交互。 |
OnChange | func()Go 零值: | 值发生变化时通知应用的回调。 |
OnLoad | func(string, TreeTicket)Go 零值: | 请求加载子节点时通知应用的回调。 |
UI | StylesGo 零值: | 以部件名称为键覆盖外观和间距。 |
Style | func(Slot, ui.Element)Go 零值: | 同步配置当前构建的部件;不要保留 Element。 |
TreeNode
源码type TreeNode struct {
ID, Label string
Icon *ui.SVG
Children []TreeNode
Lazy bool
}| 字段 | 类型 | 说明 |
|---|---|---|
ID | stringGo 零值: | 唯一且稳定的业务标识。 |
Label | stringGo 零值: | 控件标签或可访问名称。 |
Icon | *ui.SVGGo 零值: | 组件使用的 SVG 图标。 |
Children | []TreeNodeGo 零值: | 子项目列表。 |
Lazy | boolGo 零值: | 子节点需要延迟加载。 |