Stepper
步驟導航器組件,適用于引導用戶按照步驟完成任務的導航場景。
說明:
開發(fā)前請熟悉鴻蒙開發(fā)指導文檔 :[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md
]
該組件從API Version 8開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標單獨標記該內(nèi)容的起始版本。
子組件
僅能包含子組件[StepperItem]。
接口
Stepper(value?: { index?: number })
參數(shù):
參數(shù)名 | 參數(shù)類型 | 必填 | 參數(shù)描述 |
---|---|---|---|
index | number | 否 | 設(shè)置步驟導航器當前顯示StepperItem的索引值。 默認值:0 從API version 10開始,該參數(shù)支持[$$]雙向綁定變量。 |
屬性
無
事件
名稱 | 描述 |
---|---|
onFinish(callback: () => void) | 步驟導航器最后一個StepperItem的nextLabel被點擊時,并且ItemState屬性為Normal時,觸發(fā)該回調(diào) 。 |
onSkip(callback: () => void) | 當前顯示的StepperItem狀態(tài)為ItemState.Skip時,nextLabel被點擊時觸發(fā)該回調(diào)。 |
onChange(callback: (prevIndex?: number, index?: number) => void) | 點擊當前StepperItem的prevLabel進行步驟切換時觸發(fā)該回調(diào);或點擊當前StepperItem的nextLabel,當前頁面不為步驟導航器最后一個StepperItem且ItemState屬性為Normal時,觸發(fā)該回調(diào)。 - prevIndex:切換前的步驟頁索引值。 - index:切換后的步驟頁(前一頁或者下一頁)索引值。 |
onNext(callback: (index?: number, pendingIndex?: number) => void) | 點擊StepperItem的nextLabel切換下一步驟時,當前頁面不為步驟導航器最后一個StepperItem且ItemState屬性為Normal時,觸發(fā)該回調(diào)。 - index:當前步驟頁索引值。 - pendingIndex:下一步驟頁索引值。 |
onPrevious(callback: (index?: number, pendingIndex?: number) => void) | 點擊StepperItem的prevLabel切換上一步驟時觸發(fā)該回調(diào)。 - index:當前步驟頁索引值。 - pendingIndex:上一步驟頁索引值。HarmonyOS與OpenHarmony鴻蒙文檔籽料:mau123789是v直接拿 |
示例
// xxx.ets
@Styles function itemStyle () {
.width(336)
.height(621)
.margin({ top: 48, left: 12 })
.borderRadius(24)
.backgroundColor('#FFFFFF')
}
@Extend(Text) function itemTextStyle () {
.fontColor('#182431')
.fontSize(36)
.fontWeight(500)
.opacity(0.4)
.margin({ top: 82, bottom: 40 })
}
@Entry
@Component
struct StepperExample {
@State currentIndex: number = 0
@State firstState: ItemState = ItemState.Normal
@State secondState: ItemState = ItemState.Normal
@State thirdState: ItemState = ItemState.Normal
build() {
Stepper({
index: this.currentIndex
}) {
// 第一個步驟頁
StepperItem() {
Column() {
Text('Page One')
.itemTextStyle()
Button('change status:' + this.firstState)
.backgroundColor('#007dFF')
.onClick(() = > {
this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip
})
}.itemStyle()
}
.nextLabel('Next')
.status(this.firstState)
// 第二個步驟頁
StepperItem() {
Column() {
Text('Page Two')
.itemTextStyle()
Button('change status:' + this.secondState)
.backgroundColor('#007dFF')
.onClick(() = > {
this.secondState = this.secondState === ItemState.Disabled ? ItemState.Normal : ItemState.Disabled
})
}.itemStyle()
}
.nextLabel('Next')
.prevLabel('Previous')
.status(this.secondState)
// 第三個步驟頁
StepperItem() {
Column() {
Text('Page Three')
.itemTextStyle()
Button('change status:' + this.thirdState)
.backgroundColor('#007dFF')
.onClick(() = > {
this.thirdState = this.thirdState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting
})
}.itemStyle()
}
.status(this.thirdState)
// 第四個步驟頁
StepperItem() {
Column() {
Text('Page Four')
.itemTextStyle()
}.itemStyle()
}
}
.backgroundColor('#F1F3F5')
.onFinish(() = > {
// 此處可處理點擊最后一頁的Finish時的邏輯,例如路由跳轉(zhuǎn)等
console.info('onFinish')
})
.onSkip(() = > {
// 此處可處理點擊跳過時的邏輯,例如動態(tài)修改Stepper的index值使其跳轉(zhuǎn)到某一步驟頁等
console.info('onSkip')
})
.onChange((prevIndex?: number, index?: number) = > {
if(index){
this.currentIndex = index
}
})
}
}
審核編輯 黃宇
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。
舉報投訴
-
組件
+關(guān)注
關(guān)注
1文章
532瀏覽量
18424 -
鴻蒙
+關(guān)注
關(guān)注
60文章
2620瀏覽量
44063
發(fā)布評論請先 登錄
相關(guān)推薦
熱點推薦
HarmonyOS/OpenHarmony應用開發(fā)-ArkTS的聲明式開發(fā)范式
軌跡。狀態(tài)與數(shù)據(jù)管理狀態(tài)數(shù)據(jù)管理作為基于ArkTS的聲明式開發(fā)范式的特色,通過功能不同的裝飾器給開發(fā)者提供了清晰的頁面更新渲染流程和管道。狀態(tài)管理包括UI組件狀態(tài)和應用程序狀態(tài),兩者協(xié)
發(fā)表于 01-17 15:09
鴻蒙ArkTS聲明式組件:PatternLock
圖案密碼鎖組件,以九宮格圖案的方式輸入密碼,用于密碼驗證場景。手指在PatternLock組件區(qū)域按下時開始進入輸入狀態(tài),手指離開屏幕時結(jié)束輸入狀態(tài)完成密碼輸入。

評論