ForEach
Note:
Currently in the beta phase.
The ForEach interface performs loop rendering based on array-type data.
Import Module
import kit.ArkUI.*
class ForEach<T>
public class ForEach<T> {
public init(arr: CollectionEx<T>, itemGenerator!: ItemGeneratorFunc<T>,
keyGenerator!: ?KeyGeneratorFunc<T> = None) {}
}
Description: Creates a loop rendering component. The ForEach interface performs loop rendering based on array-type data and must be used in conjunction with container components.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
init(CollectionEx<T>, ItemGeneratorFunc<T>, ?KeyGeneratorFunc<T>)
public init(arr: CollectionEx<T>, itemGenerator!: ItemGeneratorFunc<T>, keyGenerator!: ?KeyGeneratorFunc<T> = None)
Description: Defines the ForEach component.
System Capability: SystemCapability.ArkUI.ArkUI.Full
Since: 22
Parameters:
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| arr | CollectionEx<T> | Yes | - | Array collection for UI. |
| itemGenerator | ItemGeneratorFunc<T> | Yes | - | Named parameter. Item generator function. |
| keyGenerator | ?KeyGeneratorFunc<T> | No | None | Named parameter. Key generator function. |