ListView / ListItem 可滚动列表视图
ListView 是可键盘导航的滚动列表容器,每个列表项用 ListItem 包裹,ListItem 内部可放置 Label、Static 等子组件。
基本用法
Props
ListView
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
initial_index | int | 0 | 初始聚焦(高亮)的列表项索引 |
ListItem
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| — | — | — | 内容通过默认 slot 传入(通常为 Label 或 Static) |
v-model
ListView:v-model默认绑定属性items,绑定列表项数据集合ListItem:v-model默认绑定属性label
事件
| 事件 | 说明 |
|---|---|
@list_view_selected | 列表项被按 Enter 选中时触发(ListView.Selected),event.list_view.index 为选中索引,event.item 为选中的 ListItem |
@list_view_highlighted | 键盘移动高亮时触发(ListView.Highlighted),event.list_view.index 为当前高亮索引 |
动态列表示例
通用属性
所有 Textual-vuepy 组件均支持以下属性:
| 属性 | 类型 | 说明 |
|---|---|---|
id | str | 组件 CSS ID |
style | str | TCSS 内联样式 |
class | str | TCSS 类名(空格分隔) |
border_title | str | 边框标题 |
border_subtitle | str | 边框副标题 |