harmony 鸿蒙MenuItem

2023-06-24 浏览 (629)

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

NameTypeMandatoryDescription
valueMenuItemOptions |CustomBuilderNoInformation about the menu item.

MenuItemOptions

NameTypeMandatoryDescription
startIconResourceStrNoPath to the icon displayed on the left of the menu item.
contentResourceStrNoContent of the menu item.
endIconResourceStrNoPath to the icon displayed on the right of the menu item.
labelInfoResourceStrNoInformation about the ending label, for example, shortcut Ctrl+C.
builderCustomBuilderNoBuilder for a level-2 menu.

Attributes

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

NameTypeDescription
selectedbooleanWhether the menu item is selected.
Default value: false
Since API version 10, this parameter supports $$ for two-way binding of variables.
selectIconboolean |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+FontFont style of the menu item content.
contentFontColor10+ResourceColorFont color of the menu item content.
labelFont10+FontFont style of the menu item label.
labelFontColor10+ResourceColorFont color of the menu item label.

Events

NameTypeDescription
onChange(selected: boolean) => voidTriggered 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

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