HarmonyOS NEXT鸿蒙开发:ListItemGroup的使用api 作者:马育民 • 2025-12-22 11:47 • 阅读:10001 # 介绍 [官方API](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-container-listitemgroup-V5 "官方API") 该组件用来展示列表item分组,宽度默认充满List组件,必须配合List组件来使用。 ### 应用场景 - 手机中的联系人,根据开头字母分组 - 微信发现 [](https://www.malaoshi.top/upload/0/0/1GW2S6FGbjC1.png) - 设置头、尾,如下图: [](https://www.malaoshi.top/upload/0/0/1GW2S6NytB9Q.png) # 子组件 包含ListItem子组件。 # 接口 ``` ListItemGroup(options?: ListItemGroupOptions) ``` **参数:** - options:`ListItemGroupOptions`类型,列表item分组组件参数。 # ListItemGroupOptions对象说明 - space:`number | string`类型,列表项间距。只作用于ListItem与ListItem之间,不作用于header与ListItem、footer与ListItem之间。默认值:0。单位:vp # 属性 ### divider 设置ListItem分割线样式,默认无分割线。 ``` divider(value: {strokeWidth: Length; color?: ResourceColor; startMargin?: Length; endMargin?: Length;} | null,) ``` **参数:** ``` { strokeWidth: Length, color?:ResourceColor, startMargin?: Length, endMargin?: Length } | null ``` **解释:** ListItem分割线样式: - strokeWidth: 分割线的线宽。 - color: 分割线的颜色。默认值:0x08000000 - startMargin: 分割线与列表侧边起始端的距离。默认值:0,单位:vp - endMargin: 分割线与列表侧边结束端的距离。默认值:0,单位:vp strokeWidth, startMargin和endMargin不支持设置百分比。 ListItem设置多态样式时,被按压的子组件上下的分割线不绘制。 原文出处:http://malaoshi.top/show_1GW2S6OPOqWS.html