提交 ed8e9efd 编写于 作者: J junyi233

ArkTS适配 - 告警修改

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