#鸿蒙通关秘籍#如何定制一个ArkUI的ActionSheet?

HarmonyOS
2天前
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
MOQ晨曦微光

ActionSheet适用于展示多个操作项,特别是在没有其他展示内容的情况下。以下代码示范了如何使用ActionSheet组件:

bash @Entry @Component struct ActionSheetExample { build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Button('Click to Show ActionSheet') .onClick(() => { ActionSheet.show({ title: 'ActionSheet title', subtitle: 'ActionSheet subtitle', message: 'message', autoCancel: true, confirm: { defaultFocus: true, value: 'Confirm button', action: () => { console.log('Get Alert Dialog handled') } }, alignment: DialogAlignment.Bottom, offset: { dx: 0, dy: -10 }, sheets: [ { title: 'apples', action: () => { console.log('apples') } }, { title: 'bananas', action: () => { console.log('bananas') } }, { title: 'pears', action: () => { console.log('pears') } } ] }) }) }.width('100%') .height('100%') } }

分享
微博
QQ
微信
回复
2天前
相关问题
#鸿蒙通关秘籍#怎样定制编译HAP?
72浏览 • 1回复 待解决