diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-composite-components-composetitlebar.md b/zh-cn/application-dev/reference/arkui-ts/ts-composite-components-composetitlebar.md index d4f5bb933338c107f5eb7a7497a121859d48cf41..06df2cf94287f9d424fea0d381d0a88163010e6f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-composite-components-composetitlebar.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-composite-components-composetitlebar.md @@ -59,26 +59,26 @@ ComposeTitleBar({item?: ComposeTitleBarMenuItem, title: ResourceStr, subtitle?: import { ComposeTitleBar } from "@ohos.arkui.advanced.ComposeTitleBar" import promptAction from '@ohos.promptAction' +class menuItem { + value: Resource; + isEnabled: boolean; + action: () => void + + constructor(value: Resource,isEnabled: boolean,action: () => void) { + this.value = value + this.isEnabled = isEnabled + this.action = action + } +} + @Entry @Component struct Index { - menuItems: { - value: Resource, - isEnabled: boolean, - action: () => void - }[] = [ - { isEnabled: true, value: $r('app.media.ic_public_save'), - action: () => promptAction.showToast({ message: "show toast index 1" }) - }, - { isEnabled: true, value: $r('app.media.ic_public_reduce'), - action: () => promptAction.showToast({ message: "show toast index 2" }) - }, - { isEnabled: true, value: $r('app.media.ic_public_edit'), - action: () => promptAction.showToast({ message: "show toast index 3" }) - }, - { isEnabled: true, value: $r('app.media.ic_public_reduce'), - action: () => promptAction.showToast({ message: "show toast index 4" }) - } + private menuItems:Array =[ + new menuItem($r('app.media.icon'),true,() => promptAction.showToast({ message: "show toast index 1" })), + new menuItem($r('app.media.icon'),true,() => promptAction.showToast({ message: "show toast index 2" })), + new menuItem($r('app.media.icon'),true,() => promptAction.showToast({ message: "show toast index 3" })), + new menuItem($r('app.media.icon'),true,() => promptAction.showToast({ message: "show toast index 4" })) ] build() {