harmony 鸿蒙MenuItem

  • 2023-06-24
  • 浏览 (286)

MenuItem

The <MenuItem> component represents an item in a menu.

NOTE

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

Child Components

Not supported

APIs

MenuItem(value?: MenuItemOptions|CustomBuilder)

Parameters

Name Type Mandatory Description
value MenuItemOptions |CustomBuilder No Information about the menu item.

MenuItemOptions

Name Type Mandatory Description
startIcon ResourceStr No Path to the icon displayed on the left of the menu item.
content ResourceStr No Content of the menu item.
endIcon ResourceStr No Path to the icon displayed on the right of the menu item.
labelInfo ResourceStr No Information about the ending label, for example, shortcut Ctrl+C.
builder CustomBuilder No Builder for a level-2 menu.

Attributes

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

Name Type Description
selected boolean Whether the menu item is selected.
Default value: false
Since API version 10, this parameter supports $$ for two-way binding of variables.
selectIcon boolean |ResourceStr10+ Whether to display the selected icon for a menu item is selected.
Default value: false
true: When a menu item is selected, the default tick icon is displayed.
false: When a menu item is selected, no icon is displayed.
ResourceStr: When a menu item is selected, the specified icon is displayed.
contentFont10+ Font Font style of the menu item content.
contentFontColor10+ ResourceColor Font color of the menu item content.
labelFont10+ Font Font style of the menu item label.
labelFontColor10+ ResourceColor Font color of the menu item label.

Events

Name Type Description
onChange (selected: boolean) => void Triggered when the selection status of the menu item is changed manually.
The value true means that the menu item is selected, and false means the opposite.

Example

For details, see Example in Menu.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkTS-based Declarative Development Paradigm

harmony 鸿蒙@ohos.multimedia.avCastPicker (AVCastPicker)

harmony 鸿蒙Property Animation

harmony 鸿蒙Enums

harmony 鸿蒙Blank

harmony 鸿蒙Button

harmony 鸿蒙CalendarPicker

harmony 鸿蒙Checkbox

harmony 鸿蒙CheckboxGroup

harmony 鸿蒙DataPanel

0  赞