鸿蒙移动应用技术实验
special thanks to: @weilaibudengdai
- reverse and random new game
- high score
- quit confirm
- welcome and about page
check exp constructions in ~picturebed\otherResources
, ~assets
use gameList's reverse function
Button('Reverse')
.onClick(
() => {
this.gameList.reverse()
})
use Math.random() to generate new game list
Button('New Game')
.onClick(
() => {
...
let test = Math.random()
...
})
define
PersistentStorage.PersistProp('highScore', 0);
call
@StorageLink('highScore') highScore: number = 0
define dialog window
@CustomDialog
struct CustomDialogExample {
controller: CustomDialogController
cancel: () => void
confirm: () => void
...
}
complete call back function in @Entry @Component
dialogController: CustomDialogController = new CustomDialogController({
builder: CustomDialogExample({
cancel: this.onCancel,
confirm: this.onAccept,
}),
})
onCancel() {
...
}
onAccept() {
...
}
refer to HarmonyOS Developer pages: