未验证 提交 97ad9022 编写于 作者: 1 189******51 提交者: Gitee

IssueNo: #I7X5WW:[新需求]: Rectify the arkts syntax of qs on monthly

Description: Rectify the arkts syntax of qs on monthly
Sig: SIG_ApplicaitonFramework
Feature or Bugfix: Feature
Binary Source: No

Signed-off-by: lipeicheng lipeicheng5@huawei.com
Signed-off-by: N189******51 <lipeicheng5@huawei.com>
上级 957137a6
...@@ -191,11 +191,12 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49 ...@@ -191,11 +191,12 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49
- \@LocalStorageLink绑定LocalStorage对给定的属性,建立双向数据同步。 - \@LocalStorageLink绑定LocalStorage对给定的属性,建立双向数据同步。
```ts ```ts
// 创建新实例并使用给定对象初始化 // 创建新实例并使用给定对象初始化
let storage = new LocalStorage({ 'PropA': 47 }); let storage = new LocalStorage();
storage['PropA'] = 47;
@Component @Component
struct Child { struct Child {
// @LocalStorageLink变量装饰器与LocalStorage中的'ProA'属性建立双向绑定 // @LocalStorageLink变量装饰器与LocalStorage中的'ProA'属性建立双向绑定
@LocalStorageLink('PropA') storLink2: number = 1; @LocalStorageLink('PropA') storLink2: number = 1;
...@@ -204,11 +205,11 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49 ...@@ -204,11 +205,11 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49
// 更改将同步至LocalStorage中的'ProA'以及Parent.storLink1 // 更改将同步至LocalStorage中的'ProA'以及Parent.storLink1
.onClick(() => this.storLink2 += 1) .onClick(() => this.storLink2 += 1)
} }
} }
// 使LocalStorage可从@Component组件访问 // 使LocalStorage可从@Component组件访问
@Entry(storage) @Entry(storage)
@Component @Component
struct CompA { struct CompA {
// @LocalStorageLink变量装饰器与LocalStorage中的'ProA'属性建立双向绑定 // @LocalStorageLink变量装饰器与LocalStorage中的'ProA'属性建立双向绑定
@LocalStorageLink('PropA') storLink1: number = 1; @LocalStorageLink('PropA') storLink1: number = 1;
...@@ -220,7 +221,7 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49 ...@@ -220,7 +221,7 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49
Child() Child()
} }
} }
} }
``` ```
...@@ -233,12 +234,14 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49 ...@@ -233,12 +234,14 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49
- Child组件中,Text绑定的storProp2 依旧显示47。 - Child组件中,Text绑定的storProp2 依旧显示47。
```ts ```ts
// 创建新实例并使用给定对象初始化 // 创建新实例并使用给定对象初始化
let storage = new LocalStorage({ 'PropA': 47 }); let storage = new LocalStorage();
// 使LocalStorage可从@Component组件访问 storage['PropA'] = 47;
@Entry(storage)
@Component // 使LocalStorage可从@Component组件访问
struct CompA { @Entry(storage)
@Component
struct CompA {
// @LocalStorageProp变量装饰器与LocalStorage中的'ProA'属性建立单向绑定 // @LocalStorageProp变量装饰器与LocalStorage中的'ProA'属性建立单向绑定
@LocalStorageProp('PropA') storProp1: number = 1; @LocalStorageProp('PropA') storProp1: number = 1;
...@@ -250,10 +253,10 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49 ...@@ -250,10 +253,10 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49
Child() Child()
} }
} }
} }
@Component @Component
struct Child { struct Child {
// @LocalStorageProp变量装饰器与LocalStorage中的'ProA'属性建立单向绑定 // @LocalStorageProp变量装饰器与LocalStorage中的'ProA'属性建立单向绑定
@LocalStorageProp('PropA') storProp2: number = 2; @LocalStorageProp('PropA') storProp2: number = 2;
...@@ -263,7 +266,7 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49 ...@@ -263,7 +266,7 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49
Text(`Parent from LocalStorage ${this.storProp2}`) Text(`Parent from LocalStorage ${this.storProp2}`)
} }
} }
} }
``` ```
...@@ -274,9 +277,10 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49 ...@@ -274,9 +277,10 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49
```ts ```ts
// 构造LocalStorage实例 // 构造LocalStorage实例
let storage = new LocalStorage({ 'PropA': 47 }); let storage = new LocalStorage();
storage['PropA'] = 47;
// 调用link9+接口构造'PropA'的双向同步数据,linkToPropA 是全局变量 // 调用link9+接口构造'PropA'的双向同步数据,linkToPropA 是全局变量
let linkToPropA = storage.link('PropA'); let linkToPropA = storage.link<number>('PropA');
@Entry(storage) @Entry(storage)
@Component @Component
...@@ -388,11 +392,10 @@ import UIAbility from '@ohos.app.ability.UIAbility'; ...@@ -388,11 +392,10 @@ import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window'; import window from '@ohos.window';
export default class EntryAbility extends UIAbility { export default class EntryAbility extends UIAbility {
storage: LocalStorage = new LocalStorage({ storage: LocalStorage = new LocalStorage();
'PropA': 47
});
onWindowStageCreate(windowStage: window.WindowStage) { onWindowStageCreate(windowStage: window.WindowStage) {
this.storage['PropA'] = 47;
windowStage.loadContent('pages/Index', this.storage); windowStage.loadContent('pages/Index', this.storage);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册