openharmony 鸿蒙 ts-container-gridcol

2025-06-12 浏览 (1)

GridCol

The GridCol component must be used as a child component of the GridRow container.

NOTE

This component is supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version.

Child Components

This component can contain only one child component.

APIs

GridCol(option?: GridColOptions)

Creates a GridCol component.

Widget capability: This API can be used in ArkTS widgets since API version 9.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
optionGridColOptionsNoOptions of the GridCol component.

GridColOptions

Defines the options of the GridCol component.

Widget capability: This API can be used in ArkTS widgets since API version 9.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeMandatoryDescription
spannumber |GridColColumnOptionNoNumber of columns occupied by the component. If it is set to 0, the component is not involved in layout calculation, that is, the component is not rendered.
The value is an integer greater than 0.
Default value: 1.
offsetnumber |GridColColumnOptionNoNumber of offset columns relative to the original position of the component.
The value is an integer greater than 0.
Default value: 0.
ordernumber |GridColColumnOptionNoSequence number of the component. Child components of the grid are sorted in ascending order based on their sequence numbers.
The value is an integer greater than 0.
Default value: 0.
NOTE
If a child component shares an order value with another child component or does not have order set, it is displayed based on its code sequence number.
If order is not set for all child components, those that have order set are displayed after those that do not and are sorted in ascending order based on the value.

The values of span, offset, and order attributes are inherited in the sequence of xs, sm, md, lg, xl, and xxl. If no value is set for a breakpoint, the value is obtained from the previous breakpoint.

Attributes

In addition to the universal attributes, the following attributes are supported.

span

span(value: number|GridColColumnOption)

Sets the number of columns occupied by the component. If it is set to 0, the element is not involved in layout calculation, that is, the element is not rendered.

Widget capability: This API can be used in ArkTS widgets since API version 9.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
valuenumber |GridColColumnOptionYesNumber of occupied columns.
The value is an integer greater than 0.
Default value: 1.

gridColOffset

gridColOffset(value: number|GridColColumnOption)

Sets the number of offset columns relative to the original position of the component.

Widget capability: This API can be used in ArkTS widgets since API version 9.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
valuenumber |GridColColumnOptionYesNumber of offset columns relative to the previous child component of the grid
The value is an integer greater than 0.
Default value: 0.

order

order(value: number|GridColColumnOption)

Sets the sequence number of the component. Child components of the grid are sorted in ascending order based on their sequence numbers.

Widget capability: This API can be used in ArkTS widgets since API version 9.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
valuenumber |GridColColumnOptionYesSequence number of the component. Child components of the grid are sorted in ascending order based on their sequence numbers.
The value is an integer greater than 0.
Default value: 0.

GridColColumnOption

Describes the numbers of grid columns occupied by the GridCol component on devices with different width types.

Widget capability: This API can be used in ArkTS widgets since API version 9.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeMandatoryDescription
xsnumberNoNumber of grid columns on the device where the grid size is xs.
smnumberNoNumber of grid columns on the device where the grid size is sm.
mdnumberNoNumber of grid columns on the device where the grid size is md.
lgnumberNoNumber of grid columns on the device where the grid size is lg.
xlnumberNoNumber of grid columns on the device where the grid size is xl.
xxlnumberNoNumber of grid columns on the device where the grid size is xxl.

Example

See the example for GridRow.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArcButton

harmony 鸿蒙ArcSlider

harmony 鸿蒙Chip

harmony 鸿蒙ChipGroup

harmony 鸿蒙ComposeListItem

harmony 鸿蒙ComposeTitleBar

harmony 鸿蒙advanced.Counter

harmony 鸿蒙Dialog Box (Dialog)

harmony 鸿蒙DialogV2

harmony 鸿蒙DownloadFileButton

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/QiKBd2