提交 d0eda18f 编写于 作者: B bojiang 提交者: Bo Jiang

fixed ef3033cc from https://gitee.com/BoJiang4702/docs/pulls/8041

jiangbo91@huawei.com

localstorage示例代码修改
Signed-off-by: Nbojiang <jiangbo91@huawei.com>
Change-Id: I81e9f0b68fd899ccdf074ff6b1e76b10441c8082
上级 b0a21408
...@@ -279,7 +279,7 @@ clear(): boolean ...@@ -279,7 +279,7 @@ clear(): boolean
### 示例1(在一个Ability创建的LocalStorage) ### 示例1(在一个Ability创建的LocalStorage)
```javascript ```javascript
import Ability from '@ohos.appLication.Ability' import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
storage : LocalStorage storage : LocalStorage
onCreate(want) { onCreate(want) {
...@@ -335,23 +335,23 @@ let storage = new LocalStorage({"PropA":47}); ...@@ -335,23 +335,23 @@ let storage = new LocalStorage({"PropA":47});
@Entry(storage) @Entry(storage)
@Component @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)`) Text(`Parent from LocalStorage ${ this.storLink }`)
.onClick(()=>this.storLink+=1) .onClick(()=>this.storLink+=1)
Child() Child()
} }
} }
} }
@Component @Component
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.storLink+=1)
} }
} }
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册