未验证 提交 5138b73c 编写于 作者: O openharmony_ci 提交者: Gitee

!8041 修改localstorage文档示例代码

Merge pull request !8041 from Bo Jiang/addFile
...@@ -278,8 +278,8 @@ clear(): boolean ...@@ -278,8 +278,8 @@ clear(): boolean
### 示例1(在一个Ability创建的LocalStorage) ### 示例1(在一个Ability创建的LocalStorage)
```javascript ```ts
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,10 +335,10 @@ let storage = new LocalStorage({"PropA":47}); ...@@ -335,10 +335,10 @@ 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()
} }
...@@ -348,10 +348,10 @@ struct ComA { ...@@ -348,10 +348,10 @@ struct ComA {
@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.
先完成此消息的编辑!
想要评论请 注册