Tree
v2 插件界面组件 Tree(数据)的属性、子节点与示例
分组:数据 · 子节点:不接受子节点
属性
| 属性 | 类型 |
|---|---|
nodes | JSON |
source | JSON |
expanded | JSON |
selected | JSON |
selection | none · single · multiple · checkbox |
nodeActions | JSON |
reorderable | 布尔 |
search | 布尔 |
indent | sm · md · lg |
dense | 布尔 |
empty | 节点 |
onSelect | 动作 |
onExpand | 动作 |
onReorder | 动作 |
onNodePress | 动作 |
onNodeAction | 动作 |
onSearch | 动作 |
另有所有组件都有的通用属性。动作类型的属性写动作名,或 { action, args }。
示例
组件画廊和两端比对用的就是这棵树:
代码代码代码json
{
"type": "Tree",
"props": {
"nodes": [
{
"key": "src",
"label": "src",
"children": [
{
"key": "src/main.js",
"label": "main.js",
"detail": "2 KB"
},
{
"key": "src/gateway.js",
"label": "gateway.js",
"badge": "hook"
}
]
},
{
"key": "locales",
"label": "locales",
"children": [
{
"key": "locales/en.json",
"label": "en.json"
},
{
"key": "locales/zh.json",
"label": "zh.json"
}
]
},
{
"key": "astra.plugin.json",
"label": "astra.plugin.json"
}
],
"expanded": [
"src"
],
"selected": [
"src/main.js"
],
"selection": "single",
"onSelect": "select"
}
}