文章目录完整代码核心参数详解1. 基础文本配置2. 弹窗位置3. 背景效果API194. 选项列表 sheets总结完整代码Entry Component struct ActionSheetExample { build() { Stack({ alignContent: Alignment.Top }) { Image($r(app.media.bg)) Column() { Button(ActionSheet) .margin(20) .onClick(() { this.getUIContext().showActionSheet({ title: ActionSheet Title, subtitle: ActionSheet Subtitle, message: ActionSheet Text, sheets: [ { title: Apples, action: () { console.info(apples); } }, { title: Bananas, action: () { console.info(bananas); } }, { title: Pears, action: () { console.info(pears); } } ], alignment: DialogAlignment.Center, backgroundColor: undefined, backgroundBlurStyle: BlurStyle.Thin, backgroundEffect: { radius: 60, saturation: 0, brightness: 1, color: Color.White, blurOptions: { grayscale: [20, 20] } }, }); }) }.width(100%) } } }运行效果如图核心参数详解1. 基础文本配置参数类型说明titlestring弹窗主标题subtitlestring弹窗副标题API10messagestring弹窗内容描述2. 弹窗位置参数取值说明alignmentDialogAlignment.Center弹窗在屏幕居中显示默认 Bottom3. 背景效果API19参数作用backgroundColor: undefined不设置纯色背景让模糊效果生效backgroundBlurStyle: BlurStyle.Thin轻度系统模糊backgroundEffect自定义背景效果半径、饱和度、亮度、颜色、灰度radius: 60模糊半径saturation: 0去色黑白效果brightness: 1亮度正常color: Color.White磨砂底色blurOptions: { grayscale: [20,20] }灰度强度4. 选项列表 sheets必传数组每一项为一个操作选项包含title文本和action点击回调支持添加icon字段设置选项图标总结调用方式从 API18 开始ActionSheet.show()已废弃必须使用getUIContext().showActionSheet()。backgroundEffect 要求仅支持API 19低版本运行会报错。背景设置规则开启backgroundBlurStyle时建议将backgroundColor设为undefined避免颜色冲突。生命周期ActionSheet 跟随 UIContext 生命周期页面销毁时自动回收无需手动关闭。遮罩与关闭默认点击遮罩层自动关闭可通过autoCancel: false禁止。如果这篇文章对你有帮助欢迎点赞、收藏、关注你的支持是持续创作的动力