dsttl3.xyz

  • 隐私政策
  • dstt
dsttl3
专注于用户阅读体验的响应式博客主题
  1. 首页
  2. 未分类
  3. 正文

鸿蒙next长按事件

1970-01-01 42点热度 0人点赞
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)
  }
}
标签: 暂无
最后更新:2025-09-09

dsttl3

https://dsttl3.xyz

点赞
下一篇 >

© 2025 dsttl3.xyz

Theme Kratos Made By Seaton Jiang