• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ToolBarItem
2<!--Kit: ArkUI-->
3<!--Subsystem: ArkUI-->
4<!--Owner: @CCFFWW-->
5<!--Designer: @yangfan229-->
6<!--Tester: @lxl007-->
7<!--Adviser: @HelloCrease-->
8
9通过[toolbar](ts-universal-attributes-toolbar.md#toolbar)通用属性为窗口标题栏添加工具栏项。
10
11>  **说明:**
12>
13>  该组件从API version 20开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
14>
15>  该组件一般配合[toolbar](ts-universal-attributes-toolbar.md#toolbar)通用属性进行使用。
16
17
18## 子组件
19
20仅可包含单个子组件。
21
22## 接口
23
24### ToolBarItem
25
26ToolBarItem(options?: ToolBarItemOptions)
27
28默认在标题栏对应分栏开头位置创建工具栏项,分栏位置由绑定该[toolbar](ts-universal-attributes-toolbar.md#toolbar)属性的组件所在分栏位置而定。
29
30**系统能力:** SystemCapability.ArkUI.ArkUI.Full
31
32**参数:**
33
34| 参数名  | 类型                                              | 必填 | 说明                                                         |
35| ------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
36| options | [ToolBarItemOptions](#toolbaritemoptions对象说明) | 否   | 为ToolBarItem提供可选参数,该对象内含有[ToolBarItemPlacement](#toolbaritemplacement枚举说明)枚举类型的placement参数。<br/>默认值:placement: ToolBarItemPlacement.TOP_BAR_LEADING |
37
38## 属性
39
40不支持[通用属性](ts-component-general-attributes.md)。
41
42## ToolBarItemOptions对象说明
43
44用于配置ToolBarItem的可选参数,主要通过placement设置工具栏项在标题栏的放置位置。
45
46**系统能力:** SystemCapability.ArkUI.ArkUI.Full
47
48| 名称      | 类型                                                  | 只读 | 可选 | 说明                                                         |
49| --------- | -------------------------------------------- | --------- | ---- | ------------------------------------------------------------ |
50| placement | [ToolBarItemPlacement](#toolbaritemplacement枚举说明) | 否 | 是   | 设置工具栏项的放置位置。<br/>默认值: ToolBarItemPlacement.TOP_BAR_LEADING<br/>设置为ToolBarItemPlacement.TOP_BAR_LEADING时,将工具栏项放置在对应顶部栏的开头位置。<br/>设置为ToolBarItemPlacement.TOP_BAR_TRAILING时,将工具栏项放置在对应顶部栏的末尾位置。<br/> |
51
52## ToolBarItemPlacement枚举说明
53
54定义工具栏项在标题栏对应分栏的放置位置选项。
55
56**系统能力:** SystemCapability.ArkUI.ArkUI.Full
57
58| 名称             | 值   | 说明                                       |
59| ---------------- | ---- | ------------------------------------------ |
60| TOP_BAR_LEADING  | 0    | 表示将工具栏项放置在对应顶部栏的开头位置。 |
61| TOP_BAR_TRAILING | 1    | 表示将工具栏项放置在对应顶部栏的末尾位置。 |
62
63## 示例
64
65示例代码参考[toolbar](ts-universal-attributes-toolbar.md#示例)。