W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
列表彈窗。
從API Version 8開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標(biāo)單獨(dú)標(biāo)記該內(nèi)容的起始版本。
show(value: { title: string | Resource, message: string | Resource, confirm?: {value: string | Resource, action:() => void}, cancel?:()=>void, sheets: Array<SheetInfo>, autoCancel?:boolean, alignment?: DialogAlignment, offset?: { dx: number | string | Resource; dy: number | string | Resource } })
定義列表彈窗并彈出。
參數(shù):
參數(shù)名 | 參數(shù)類型 | 必填 | 參數(shù)描述 |
---|---|---|---|
title | Resource | string | 是 | 彈窗標(biāo)題。 |
message | Resource | string | 是 | 彈窗內(nèi)容。 |
autoCancel | boolean | 否 | 點(diǎn)擊遮障層時(shí),是否關(guān)閉彈窗。 默認(rèn)值:true |
confirm | { value: ResourceStr, action: () => void } | 否 | 確認(rèn)按鈕的文本內(nèi)容和點(diǎn)擊回調(diào)。 默認(rèn)值: value:按鈕文本內(nèi)容。 action: 按鈕選中時(shí)的回調(diào)。 |
cancel | () => void | 否 | 點(diǎn)擊遮障層關(guān)閉dialog時(shí)的回調(diào)。 |
alignment | DialogAlignment | 否 | 彈窗在豎直方向上的對(duì)齊方式。 默認(rèn)值:DialogAlignment.Bottom |
offset | { dx: Length, dy: Length } | 否 | 彈窗相對(duì)alignment所在位置的偏移量。{ dx: 0, dy: 0 } |
sheets | Array<SheetInfo> | 是 | 設(shè)置選項(xiàng)內(nèi)容,每個(gè)選擇項(xiàng)支持設(shè)置圖片、文本和選中的回調(diào)。 |
參數(shù)名 | 參數(shù)類型 | 必填 | 參數(shù)描述 |
---|---|---|---|
title | ResourceStr | 是 | 選項(xiàng)的文本內(nèi)容。 |
icon | ResourceStr | 否 | 選項(xiàng)的圖標(biāo),默認(rèn)無圖標(biāo)顯示。 |
action | ()=>void | 是 | 選項(xiàng)選中的回調(diào)。 |
- @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',
- message: 'message',
- autoCancel: true,
- confirm: {
- value: 'Confirm button',
- action: () => {
- console.log('Get Alert Dialog handled')
- }
- },
- cancel: () => {
- console.log('actionSheet canceled')
- },
- 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%')
- }
- }
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: