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 })
  }
}
阅读 536
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 })
  }
}