提交 1689bf8e 编写于 作者: J jiangbo

jiangbo91@huawei.com

add local_storage
Signed-off-by: Njiangbo <jiangbo91@huawei.com>
Change-Id: I7a350c2c58e00371dfef617eade74b92a4549caf
上级 f3a44851
...@@ -58,19 +58,19 @@ export default class MainAbility extends Ability { ...@@ -58,19 +58,19 @@ export default class MainAbility extends Ability {
console.log("[Demo MainAbility onDestroy]") console.log("[Demo MainAbility onDestroy]")
} }
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
// Main window is created,set main page for this ability // Main window is created,set main page for this ability
windowStage.setUlContent(this.context,"pages/index",this.storage) windowStage.setUlContent(this.context,"pages/index",this.storage)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
// Main window is destroyed,release Ul related resources // Main window is destroyed,release Ul related resources
console.log("[Demo] MainAbility onWindoeStageDestroy") console.log("[Demo] MainAbility onWindoeStageDestroy")
} }
onForeground() { onForeground() {
// Ability has brought to foreground // Ability has brought to foreground
console.log("[Demo] MainAbility onForeground") console.log("[Demo] MainAbility onForeground")
} }
onBackground() { onBackground() {
// Ability has back to background // Ability has back to background
console.log("[Demo] MainAbility onBackground") console.log("[Demo] MainAbility onBackground")
}} }}
``` ```
...@@ -102,15 +102,16 @@ struct LocalStorageComponent { ...@@ -102,15 +102,16 @@ struct LocalStorageComponent {
``` ```
let storage = new LocalStorage({"PropA":47}); let storage = new LocalStorage({"PropA":47});
@Entry(storage) @Entry(storage)
@Componentstruct ComA { @Componentstruct
struct ComA {
@LocalStorageLink("PropA") storLink : number = 1; @LocalStorageLink("PropA") storLink : number = 1;
build() { build() {
Column() { Column() {
Text(`Parent from LocalStorage $(this.storLink)`) Text(`Parent from LocalStorage $(this.storLink)`) .onClick(()=>this.storLink+=1)
.onClick(()=>this.storLink+=1)
Child() Child()
} }
}} }
}
@Component @Component
...@@ -119,5 +120,6 @@ struct Child{ ...@@ -119,5 +120,6 @@ struct Child{
build() { build() {
Text(`Parent from LocalStorage $(this.storLink)`) Text(`Parent from LocalStorage $(this.storLink)`)
.onClick(()=>this.storLink1+=1) .onClick(()=>this.storLink1+=1)
}} }
}
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册