From 48a403f01fb2b7ccfb241133b417d7e702fbfc85 Mon Sep 17 00:00:00 2001 From: xu Date: Wed, 14 Sep 2022 14:28:28 +0800 Subject: [PATCH] =?UTF-8?q?review=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xu --- .../ui/ts-performance-improvement-recommendation.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/zh-cn/application-dev/ui/ts-performance-improvement-recommendation.md b/zh-cn/application-dev/ui/ts-performance-improvement-recommendation.md index 4f2bc2977b..75909c1c86 100644 --- a/zh-cn/application-dev/ui/ts-performance-improvement-recommendation.md +++ b/zh-cn/application-dev/ui/ts-performance-improvement-recommendation.md @@ -260,13 +260,15 @@ struct MyComponent { ``` ## 减少应用滑动白块 -应用通过增大List/Grid控件的cachedCount参数,可以调整UI的加载范围。cachedCount含义是屏幕外,预加载item的个数。
如果有网络图片请求,可以在滑动到屏幕显示之前,提前下载好内容,从而减少滑动白块。
+应用通过增大List/Grid控件的cachedCount参数,调整UI的加载范围。cachedCount表示屏幕外List/Grid预加载item的个数。 +如果需要请求网络图片,可以在item滑动到屏幕显示之前,提前下载好内容,从而减少滑动白块。 如下是使用cachedCount参数的例子: + ```ts @Entry @Component struct MyComponent { - private source: MyDataSource = new MyDataSource() + private source: MyDataSource = new MyDataSource(); build() { List() { LazyForEach (this.source, item => { @@ -278,11 +280,11 @@ struct MyComponent { }) } }) - }.cachedCount(3) // 扩大数值可以看到上面appear日志范围会变大 + }.cachedCount(3) // 扩大数值appear日志范围会变大 } } class MyDataSource implements IDataSource { - data: number[] = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] + data: number[] = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; public totalCount(): number { return this.data.length } @@ -295,6 +297,6 @@ class MyDataSource implements IDataSource { } } ``` -**负面影响:**
+**使用说明:**
cachedCount的增加会增大UI的cpu、内存开销。
使用时需要根据实际情况,综合性能和用户体验进行调整。 \ No newline at end of file -- GitLab