当前位置: 首页 未命名

鸿蒙next长按事件

栏目:未命名 作者:dsttl3 时间:1970-01-01 08:00:00
import { promptAction } from '@kit.ArkUI';

@Entry
@Component
struct ButtonExample  {
  @State message: string = 'Button';

  build() {
    Column() {
      Button(this.message)
        .fontSize(22)
        .fontWeight(FontWeight.Bold)
        .gesture(
          LongPressGesture({ repeat: true })
            .onAction((event?: GestureEvent) => {
              if (event) {
                promptAction.showToast({
                  message: '长按了Button',
                  duration: 2000
                })
              }
            })
        )
        .onClick(() => {
          promptAction.showToast({
            message: '点击了Button',
            duration: 2000
          })
        })
    }
    .height('100%')
    .width('100%')
    .justifyContent(FlexAlign.Center)
  }
}
阅读:2555次

相关文章

分类栏目