提交 ed8e9efd 编写于 作者: J junyi233

ArkTS适配 - 告警修改

Signed-off-by: Njunyi233 <zhengjun29@huawei.com>
上级 bce252b8
......@@ -621,7 +621,7 @@ struct Parent {
```ts
class Outer {
innerArrayProp : ObservedArray<string>;
innerArrayProp : ObservedArray<string> = [];
...
}
```
......@@ -689,7 +689,7 @@ struct ViewB {
(item: ClassA) => {
ViewA({ label: `#${item.id}`, a: item })
},
(item: ClassA) => item.id.toString()
(item: ClassA): string => { return item.id.toString(); }
)
Divider().height(10)
......@@ -738,7 +738,7 @@ struct ViewB {
@Component
struct ViewA {
@Prop a: ClassA;
@Prop a: ClassA = new ClassA(0);
label : string = "ViewA1";
build() {
......@@ -903,7 +903,7 @@ export class ObservedArray<T> extends Array<T> {
@ObjectLink me : Person;
@ObjectLink contacts : ObservedArray<Person>;
@State selectedPerson: Person = undefined;
@State selectedPerson: Person = new Person("", "", 0, "", []);
aboutToAppear() {
this.selectedPerson = this.me;
......@@ -919,7 +919,7 @@ export class ObservedArray<T> extends Array<T> {
ForEach(this.contacts, (contact: Person) => {
PersonView({ person: contact, phones: contact.phones as ObservedArray<string>, selectedPerson: this.$selectedPerson })
},
(contact: Person) => contact.id_
(contact: Person): string => { return contact.id_; }
)
Divider().height(8)
......@@ -1295,7 +1295,7 @@ export class ObservedArray<T> extends Array<T> {
ForEach(this.contacts, (contact: Person) => {
PersonView({ person: contact, phones: contact.phones as ObservedArray<string>, selectedPerson: this.$selectedPerson })
},
(contact: Person) => contact.id_
(contact: Person): string => { return contact.id_; }
)
Divider().height(8)
......
......@@ -507,8 +507,8 @@ incrSubCounter和setSubCounter都是同一个SubCounter的函数。在第一个
```ts
@ObjectLink valueParentCounter;
@ObjectLink subValueSubCounter;
@ObjectLink valueParentCounter = new ParentCounter(0);
@ObjectLink subValueSubCounter = new SubCounter(0);
```
该方法使得\@ObjectLink分别代理了ParentCounter和SubCounter的属性,这样对于这两个类的属性的变化都可以观察到,即都会对UI视图进行刷新。即使删除了上面所说的this.counter[0].incrCounter(),UI也会进行正确的刷新。
......@@ -715,8 +715,8 @@ struct ParentComp {
```ts
@Component
struct CounterComp {
@Prop value: ParentCounter;
@Prop subValue: SubCounter;
@Prop value: ParentCounter = new ParentCounter(0);
@Prop subValue: SubCounter = new SubCounter(0);
build() {
Column({ space: 10 }) {
Text(`this.subValue.counter: ${this.subValue.counter}`)
......@@ -948,8 +948,8 @@ build函数中更改应用状态的行为可能会比上面的示例更加隐蔽
```ts
@State arr : Array<..> = [ ... ];
ForEach(this.arr.sort().filter(....),
@State arr : Array<...> = [ ... ];
ForEach(this.arr.sort().filter(...),
item => {
...
})
......@@ -959,7 +959,7 @@ ForEach(this.arr.sort().filter(....),
```ts
ForEach(this.arr.filter(....).sort(),
ForEach(this.arr.filter(...).sort(),
item => {
...
})
......
......@@ -60,7 +60,7 @@
```ts
@Component
struct TotalView {
@Prop @Watch('onCountUpdated') count: number;
@Prop @Watch('onCountUpdated') count: number = 0;
@State total: number = 0;
// @Watch cb
onCountUpdated(propName: string): void {
......
......@@ -145,6 +145,7 @@ export { nativeMulti } from './utils/nativeTest'
```ts
// entry/src/main/ets/pages/index.ets
import { Log, add, MyTitleBar, ResManager, nativeMulti } from "library"
import { BusinessError } from '@ohos.base';
@Entry
@Component
......@@ -172,7 +173,7 @@ struct Index {
.then(value => {
console.log("getStringValue is " + value);
})
.catch(error => {
.catch((err: BusinessError) => {
console.log("getStringValue promise error is " + error);
});
})
......
......@@ -275,6 +275,7 @@
// Index.ets
// 导入页面路由模块
import router from '@ohos.router';
import { BusinessError } from '@ohos.base';
@Entry
@Component
......@@ -306,7 +307,7 @@
// 跳转到第二页
router.pushUrl({ url: 'pages/Second' }).then(() => {
console.info('Succeeded in jumping to the second page.')
}).catch((err) => {
}).catch((err: BusinessError) => {
console.error(`Failed to jump to the second page.Code is ${err.code}, message is ${err.message}`)
})
})
......@@ -326,6 +327,7 @@
// Second.ets
// 导入页面路由模块
import router from '@ohos.router';
import { BusinessError } from '@ohos.base';
@Entry
@Component
......@@ -358,7 +360,9 @@
router.back()
console.info('Succeeded in returning to the first page.')
} catch (err) {
console.error(`Failed to return to the first page.Code is ${err.code}, message is ${err.message}`)
let code = (err as BusinessError).code;
let message = (err as BusinessError).message;
console.error(`Failed to return to the first page.Code is ${code}, message is ${message}`)
}
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册