本文档介绍了 Item 组件及其变体,用于在 Ionic Framework 中创建列表和内容容器。Item 组件是构建跨移动和 Web 应用程序的交互式列表界面以及移动和 Web 应用程序的基础构建块。
有关通常与列表配合使用的 Refresher 组件的信息,请参阅 Refresher Component。
Ionic 中的 Item 组件是多功能的容器,用于以结构化的格式显示内容和启用用户交互。它们是创建具有跨平台一致样式和行为的列表、表单和导航元素的元素。
来源: core/src/components/item/item.tsx23-31
Ion Item 组件是 Ionic UI 系统中的基础构建块,使用 Stencil 作为 Web 组件实现。根据其配置,它可以呈现多种形式。
来源: core/src/components/item/item.tsx31-383
Item 组件支持许多属性来决定其行为和外观
| 属性 | 类型 | 描述 |
|---|---|---|
color | 颜色 | 设置应用主题的颜色 |
button | 布尔值 | 使 Item 能够通过 button 标签进行点击 |
detail | 布尔值 | 显示详细信息箭头(chevron) |
detailIcon | 字符串 | 自定义详细信息箭头图标 |
disabled | 布尔值 | 禁用用户交互 |
download | 字符串 | 用于可下载链接(带有 href) |
href | 字符串 | 用于导航的 URL(渲染为 anchor) |
lines | `'full'` | `'inset'` |
routerDirection | RouterDirection | 使用路由器的导航方向 |
类型 | `'submit'` | `'reset'` |
来源: core/src/components/item/item.tsx41-116
Item 组件提供了一个灵活的结构,带有命名插槽用于内容组织
该组件的 DOM 结构在不同的设备和方向上提供了统一的定位
来源: core/src/components/item/item.tsx16-22 core/src/components/item/item.tsx361-377
Ion Item 根据其配置和内容实现各种交互行为
交互行为会根据 Item 的内容进行调整
来源: core/src/components/item/item.tsx178-201 core/src/components/item/item.tsx274-315
当 Item 配置为 button="true" 或带有 href 属性时,Item 将作为交互式元素
该组件会根据这些属性自动渲染相应的元素(按钮或链接)。
来源: core/src/components/item/item.tsx49-51 core/src/components/item/item.tsx77-81
Items 可以显示一个详细信息指示器(通常是 chevron 图标),以表明点击会显示更多信息
在 iOS 模式下,当 Item 可点击(具有 button 或 href)时,会自动添加详细信息指示器。
来源: core/src/components/item/item.tsx56-62 core/src/components/item/item.tsx317-376
lines 属性控制项目之间的边框外观
此属性有助于构建列表中的视觉层次结构。
来源: core/src/components/item/item.tsx92-93 core/src/components/item/item.tsx340-341
Item 组件能很好地处理表单输入和交互元素
组件会自动检测输入元素并调整其行为
来源: core/src/components/item/item.tsx182-201 core/src/components/item/item.tsx298-310
Items 通常在列表容器中使用,以创建结构化内容
当 Item 在 ion-list 中使用时,Item 将获得适当的 ARIA role="listitem" 以实现可访问性。
来源: core/src/components/item/item.tsx322-323 core/src/components/item/item.tsx351-352
Item 组件通过 color 属性和 CSS 自定义属性支持 Ionic 的主题系统
该组件会自动应用适当的特定于模式的样式(iOS 或 Material Design)。
来源: core/src/components/item/item.tsx41-46 core/src/utils/theme.ts11-19
Item 组件对交互元素有复杂的处理
它识别潜在的交互元素
基于检测到的元素,它会调整其交互模型,以避免与单独的元素交互冲突。
来源: core/src/components/item/item.tsx182-201 core/src/components/item/item.tsx235-239
当 Item 包含交互元素时,它会管理事件传播以确保正确的行为
来源: core/src/components/item/item.tsx274-315
href 或 button 属性lines 属性来控制 Item 之间的视觉分隔Item 组件与 Ionic Framework 中的其他组件紧密协作
有关列表的下拉刷新功能,请参阅 Refresher Component。
刷新此 Wiki
最后索引时间2025 年 4 月 18 日(b0d88e)