提交 2a7603aa 编写于 作者: J jiangbo

jiangbo91@huawei.com

add local_storage
Signed-off-by: Njiangbo <jiangbo91@huawei.com>
Change-Id: I75f51188e75df9d8e321ab5883602236cadfd029
上级 1689bf8e
...@@ -72,7 +72,8 @@ export default class MainAbility extends Ability { ...@@ -72,7 +72,8 @@ export default class MainAbility extends Ability {
onBackground() { onBackground() {
// Ability has back to background // Ability has back to background
console.log("[Demo] MainAbility onBackground") console.log("[Demo] MainAbility onBackground")
}} }
}
``` ```
获取页面: 获取页面:
...@@ -89,8 +90,8 @@ struct LocalStorageComponent { ...@@ -89,8 +90,8 @@ struct LocalStorageComponent {
.onClick(()=>{ .onClick(()=>{
this.simpleVarName +=1; this.simpleVarName +=1;
}) })
Text(JSON.stringify(this.simpleVarName)) Text(JSON.stringify(this.simpleVarName))
.fontSize(50) .fontSize(50)
} }
.height(500) .height(500)
} }
...@@ -102,14 +103,15 @@ struct LocalStorageComponent { ...@@ -102,14 +103,15 @@ struct LocalStorageComponent {
``` ```
let storage = new LocalStorage({"PropA":47}); let storage = new LocalStorage({"PropA":47});
@Entry(storage) @Entry(storage)
@Componentstruct @Component
struct ComA { struct ComA {
@LocalStorageLink("PropA") storLink : number = 1; @LocalStorageLink("PropA") storLink : number = 1;
build() { build() {
Column() { Column() {
Text(`Parent from LocalStorage $(this.storLink)`) .onClick(()=>this.storLink+=1) Text(`Parent from LocalStorage $(this.storLink)`)
Child() .onClick(()=>this.storLink+=1)
} Child()
}
} }
} }
...@@ -118,8 +120,8 @@ struct ComA { ...@@ -118,8 +120,8 @@ struct ComA {
struct Child{ struct Child{
@LocalStorageLink("PropA") storLink : number = 1; @LocalStorageLink("PropA") storLink : number = 1;
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.
先完成此消息的编辑!
想要评论请 注册