# 10.3:ActionSheet

ActionSheet的介绍使用

# 10.3.1:语法介绍

import { promptAction } from '@kit.ArkUI';

@Entry
@ComponentV2
struct Index {

  build() {
    Column({space: 10}) {
      Button("ActionSheet")
        .onClick(() => {
          this.showActionSheet()
        })
    }
    .width('100%')
  }

  private showActionSheet() {
    let sheets: Array<SheetInfo> = [
      {
        title: "标题1",
        action: () => {
          promptAction.showToast({ message: "点击标题1" })
        }
      },
      {
        title: "标题2",
        action: () => {
          promptAction.showToast({ message: "点击标题2" })
        }
      },
      {
        title: "标题3",
        action: () => {
          promptAction.showToast({ message: "点击标题3" })
        }
      }
    ]
    let dialog: ActionSheetOptions = {
      sheets: sheets,
      message: "弹窗内容",
      title: "弹窗标题",
      subtitle: "弹窗副标题",
      autoCancel: false,
      cancel: () => {
        promptAction.showToast({ message: "点击返回键" })
      },
      backgroundColor: "#aabbcc",
      cornerRadius: 10,
      borderWidth: 2,
      borderColor: Color.Red,
      borderStyle: BorderStyle.Solid,
      backgroundBlurStyle: BlurStyle.Thin,
      confirm: {
        enabled: true,
        value: "按钮文字",
        defaultFocus: true,
        action: () => {
          promptAction.showToast({ message: "点击了按钮" })
        }
      }
    }
    ActionSheet.show(dialog)
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
请作者喝杯咖啡

津公网安备 12011402001367号

津ICP备2020008934号-2

中央网信办互联网违法和不良信息举报中心

天津市互联网违法和不良信息举报中心