当前位置:首页 > 未命名 > 正文内容

鸿蒙next长按事件

dsttl34个月前 (05-25)未命名485
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)
  }
}

扫描二维码推送至手机访问。

版权声明:本文由dsttl3发布,如需转载请注明出处。

本文链接:https://dsttl3.cn/?id=490

分享给朋友: