diff --git a/zh-cn/application-dev/performance/improve-application-startup-and-response/improve-application-cold-start-speed.md b/zh-cn/application-dev/performance/improve-application-startup-and-response/improve-application-cold-start-speed.md index 5c74b68967bac572396a5c85782fc35d1b4d3ed8..daad5a996516e5d43594c3dc08211cb09e937726 100644 --- a/zh-cn/application-dev/performance/improve-application-startup-and-response/improve-application-cold-start-speed.md +++ b/zh-cn/application-dev/performance/improve-application-startup-and-response/improve-application-cold-start-speed.md @@ -100,11 +100,9 @@ struct Index { // 运算任务异步处理 private computeTaskAsync() { - new Promise((resolved, rejected) => { - setTimeout(() => { // 这里使用setTimeout来实现异步延迟运行 - this.computeTask(); - }, 1000) - }) + setTimeout(() => { // 这里使用setTimeout来实现异步延迟运行 + this.computeTask(); + }, 1000) } } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/performance/improve-application-startup-and-response/improve-application-response.md b/zh-cn/application-dev/performance/improve-application-startup-and-response/improve-application-response.md index 98466b306c6590d2f628be1452e4f217fd75b88d..b21b23596146c7885b6f6a3d7f98b5c7ecc01b70 100644 --- a/zh-cn/application-dev/performance/improve-application-startup-and-response/improve-application-response.md +++ b/zh-cn/application-dev/performance/improve-application-startup-and-response/improve-application-response.md @@ -40,7 +40,7 @@ struct ImageExample1 { ```typescript @Entry @Component -struct ImageExample1 { +struct ImageExample2 { build() { Column() { Row() { @@ -78,7 +78,7 @@ function computeTask(arr: string[]): string[] { @Entry @Component -struct AspectRatioExample { +struct AspectRatioExample3 { @State children: string[] = ['1', '2', '3', '4', '5', '6']; aboutToAppear() { @@ -88,8 +88,7 @@ struct AspectRatioExample { async computeTaskInTaskPool() { const param = this.children.slice(); let task = new taskpool.Task(computeTask, param); - // @ts-ignore - this.children = await taskpool.execute(task); + await taskpool.execute(task); } build() { @@ -105,7 +104,7 @@ struct AspectRatioExample { ```typescript @Entry @Component -struct AspectRatioExample { +struct AspectRatioExample4 { @State private children: string[] = ['1', '2', '3', '4', '5', '6']; private count: number = 0; @@ -123,11 +122,9 @@ struct AspectRatioExample { } computeTaskAsync() { - new Promise((resolved, rejected) => { - setTimeout(() => { // 这里使用setTimeout来实现异步延迟运行 - this.computeTask(); - }, 1000) - }) + setTimeout(() => { // 这里使用setTimeout来实现异步延迟运行 + this.computeTask(); + }, 1000) } build() { @@ -149,7 +146,7 @@ struct AspectRatioExample { ```typescript @Entry @Component -struct StackExample { +struct StackExample5 { @State isVisible : boolean = false; build() { @@ -178,7 +175,7 @@ struct StackExample { ```typescript @Entry @Component -struct StackExample { +struct StackExample6 { @State isVisible : boolean = false; build() { @@ -211,8 +208,8 @@ struct StackExample { ```typescript @Entry @Component -struct MyComponent { - @State arr: number[] = Array.from(Array(10000), (v,k) =>k); +struct MyComponent7 { + @State arr: number[] = Array.from(Array(10000), (v,k) =>k); build() { List() { ForEach(this.arr, (item: number) => { @@ -235,8 +232,8 @@ class BasicDataSource implements IDataSource { return 0 } - public getData(index: number): any { - return undefined + public getData(index: number): string { + return '' } registerDataChangeListener(listener: DataChangeListener): void { @@ -286,13 +283,13 @@ class BasicDataSource implements IDataSource { } class MyDataSource extends BasicDataSource { - private dataArray: string[] = Array.from(Array(10000), (v, k) => k.toString()); + private dataArray: string[] = Array.from(Array(10000), (v, k) => k.toString()); public totalCount(): number { return this.dataArray.length } - public getData(index: number): any { + public getData(index: number): string { return this.dataArray[index] } @@ -318,7 +315,7 @@ struct MyComponent { ListItem() { Text(item).fontSize(20).margin({ left: 10 }) } - }, item => item) + }, (item:string) => item) } } } diff --git a/zh-cn/application-dev/performance/reduce-frame-loss-and-frame-freezing/reduce-view-nesting-levels.md b/zh-cn/application-dev/performance/reduce-frame-loss-and-frame-freezing/reduce-view-nesting-levels.md index d2df662443abfb850ede59ea9e66f0c80f93fabb..c9337880dfaa220cfbac775d5586517ed6458c55 100644 --- a/zh-cn/application-dev/performance/reduce-frame-loss-and-frame-freezing/reduce-view-nesting-levels.md +++ b/zh-cn/application-dev/performance/reduce-frame-loss-and-frame-freezing/reduce-view-nesting-levels.md @@ -9,13 +9,13 @@ ```typescript @Entry @Component -struct AspectRatioExample { - @State children: Number[] = Array.from(Array(900), (v, k) => k); +struct AspectRatioExample12 { + @State children: Number[] = Array.from(Array(900), (v, k) => k); build() { Scroll() { Grid() { - ForEach(this.children, (item) => { + ForEach(this.children, (item:Number[]) => { GridItem() { Stack() { Stack() { @@ -25,7 +25,7 @@ struct AspectRatioExample { } } } - }, item => item) + }, (item:string) => item) } .columnsTemplate('1fr 1fr 1fr 1fr') .columnsGap(0) @@ -41,17 +41,17 @@ struct AspectRatioExample { ```typescript @Entry @Component -struct AspectRatioExample { +struct AspectRatioExample11 { @State children: Number[] = Array.from(Array(900), (v, k) => k); build() { Scroll() { Grid() { - ForEach(this.children, (item) => { + ForEach(this.children, (item:Number[]) => { GridItem() { Text(item.toString()) } - }, item => item) + }, (item:string) => item) } .columnsTemplate('1fr 1fr 1fr 1fr') .columnsGap(0)