HarmonyOS bindMenu怎么设置往左下方出菜单?

怎么设置往左下角出菜单

// xxx.ets
@Entry
@Component
struct MenuExample {
  build() {
    Column() {
      Text('click')
        .bindMenu([
          {
            value: 'Menu1',
            action: () => {
              console.info('handle Menu1 select')
            }
          },
          {
            value: 'Menu2',
            action: () => {
              console.info('handle Menu2 select')
            }
          },
        ])
    }
    .width('100%')
    .margin({ top: 105 })
  }
}
阅读 537
1 个回答

如果bindcontextmenu满足不了需求,那使用bindMenu,设置placement: Placement.BottomRight动效可从右上到左下。

参考demo:

@Entry
@Component
struct MenuExample {
  build() {
    Column() {
      Text('click')
        .bindMenu([
          {
            value: 'Menu1',
            action: () => {
              console.info('handle Menu1 select')
            }
          },
          {
            value: 'Menu2',
            action: () => {
              console.info('handle Menu2 select')
            }
          },
        ],{
          placement: Placement.BottomRight
        }
        )
    }
    .width('90%')
    .margin({ top: 105 })
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进