You need to sign in or sign up before continuing.
提交 2bbe7e3e 编写于 作者: S sqsyqqy

ArkTS告警处理

Signed-off-by: Nsqsyqqy <sunqi57@huawei.com>
上级 3f3fb2ac
...@@ -69,7 +69,7 @@ OpenHarmony的应用冷启动过程大致可分成以下四个阶段:应用进 ...@@ -69,7 +69,7 @@ OpenHarmony的应用冷启动过程大致可分成以下四个阶段:应用进
aboutToAppear函数会在创建自定义组件实例后,页面绘制之前执行,以下代码在aboutToAppear中对耗时长的计算任务进行了异步处理,避免在该接口执行该耗时操作,不阻塞页面绘制。 aboutToAppear函数会在创建自定义组件实例后,页面绘制之前执行,以下代码在aboutToAppear中对耗时长的计算任务进行了异步处理,避免在该接口执行该耗时操作,不阻塞页面绘制。
```javascript ```typescript
@Entry @Entry
@Component @Component
struct Index { struct Index {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
OpenHarmony提供的Image组件默认生效异步加载特性,当应用在页面上展示一批本地图片的时候,会先显示空白占位块,当图片在其他线程加载完毕后,再替换占位块。这样图片加载就可以不阻塞页面的显示,给用户带来良好的交互体验。因此,只在加载图片耗时比较短的情况下建议下述代码。 OpenHarmony提供的Image组件默认生效异步加载特性,当应用在页面上展示一批本地图片的时候,会先显示空白占位块,当图片在其他线程加载完毕后,再替换占位块。这样图片加载就可以不阻塞页面的显示,给用户带来良好的交互体验。因此,只在加载图片耗时比较短的情况下建议下述代码。
```javascript ```typescript
@Entry @Entry
@Component @Component
struct ImageExample1 { struct ImageExample1 {
...@@ -37,7 +37,7 @@ struct ImageExample1 { ...@@ -37,7 +37,7 @@ struct ImageExample1 {
建议:在加载图片的耗时比较短的时候,通过异步加载的效果会大打折扣,建议配置Image的syncLoad属性。 建议:在加载图片的耗时比较短的时候,通过异步加载的效果会大打折扣,建议配置Image的syncLoad属性。
```javascript ```typescript
@Entry @Entry
@Component @Component
struct ImageExample1 { struct ImageExample1 {
...@@ -63,7 +63,7 @@ struct ImageExample1 { ...@@ -63,7 +63,7 @@ struct ImageExample1 {
OpenHarmony提供了[TaskPool线程池](../../reference/apis/js-apis-taskpool.md),相比worker线程,TaskPool提供了任务优先级设置、线程池自动管理机制,示例如下: OpenHarmony提供了[TaskPool线程池](../../reference/apis/js-apis-taskpool.md),相比worker线程,TaskPool提供了任务优先级设置、线程池自动管理机制,示例如下:
```javascript ```typescript
import taskpool from '@ohos.taskpool'; import taskpool from '@ohos.taskpool';
@Concurrent @Concurrent
...@@ -102,7 +102,7 @@ struct AspectRatioExample { ...@@ -102,7 +102,7 @@ struct AspectRatioExample {
以下代码展示了将一个长时间执行的非UI任务通过Promise声明成异步任务,主线程可以先进行用户反馈-绘制初始页面。等主线程空闲时,再执行异步任务。等到异步任务运行完毕后,重绘相关组件刷新页面。 以下代码展示了将一个长时间执行的非UI任务通过Promise声明成异步任务,主线程可以先进行用户反馈-绘制初始页面。等主线程空闲时,再执行异步任务。等到异步任务运行完毕后,重绘相关组件刷新页面。
```javascript ```typescript
@Entry @Entry
@Component @Component
struct AspectRatioExample { struct AspectRatioExample {
...@@ -146,7 +146,7 @@ struct AspectRatioExample { ...@@ -146,7 +146,7 @@ struct AspectRatioExample {
以下代码的Text('New Page')组件被状态变量isVisible控制,isVisible为true时创建,false时销毁。当isVisible发生变化时,Stack容器内的所有组件都会刷新: 以下代码的Text('New Page')组件被状态变量isVisible控制,isVisible为true时创建,false时销毁。当isVisible发生变化时,Stack容器内的所有组件都会刷新:
```javascript ```typescript
@Entry @Entry
@Component @Component
struct StackExample { struct StackExample {
...@@ -175,7 +175,7 @@ struct StackExample { ...@@ -175,7 +175,7 @@ struct StackExample {
建议:对于这种受状态变量控制的组件,在if外套一层容器,减少刷新范围。 建议:对于这种受状态变量控制的组件,在if外套一层容器,减少刷新范围。
```javascript ```typescript
@Entry @Entry
@Component @Component
struct StackExample { struct StackExample {
...@@ -208,7 +208,7 @@ struct StackExample { ...@@ -208,7 +208,7 @@ struct StackExample {
反例:this.arr中的每一项元素都被初始化和加载,数组中的元素有10000个,主线程执行耗时长。 反例:this.arr中的每一项元素都被初始化和加载,数组中的元素有10000个,主线程执行耗时长。
```javascript ```typescript
@Entry @Entry
@Component @Component
struct MyComponent { struct MyComponent {
...@@ -227,7 +227,7 @@ struct MyComponent { ...@@ -227,7 +227,7 @@ struct MyComponent {
建议:这种情况下用LazyForEach替换ForEach,LazyForEach一般只加载可见的元素,避免一次性初始化和加载所有元素。 建议:这种情况下用LazyForEach替换ForEach,LazyForEach一般只加载可见的元素,避免一次性初始化和加载所有元素。
```javascript ```typescript
class BasicDataSource implements IDataSource { class BasicDataSource implements IDataSource {
private listeners: DataChangeListener[] = [] private listeners: DataChangeListener[] = []
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
反例:应用使用了自定义动画,动画曲线计算过程很容易引起UI线程高负载,易导致丢帧。 反例:应用使用了自定义动画,动画曲线计算过程很容易引起UI线程高负载,易导致丢帧。
```javascript ```typescript
@Entry @Entry
@Component @Component
struct AttrAnimationExample { struct AttrAnimationExample {
...@@ -56,7 +56,7 @@ struct AttrAnimationExample { ...@@ -56,7 +56,7 @@ struct AttrAnimationExample {
建议:通过系统提供的属性动效API实现上述动效功能。 建议:通过系统提供的属性动效API实现上述动效功能。
```javascript ```typescript
@Entry @Entry
@Component @Component
struct AttrAnimationExample { struct AttrAnimationExample {
...@@ -96,7 +96,7 @@ struct AttrAnimationExample { ...@@ -96,7 +96,7 @@ struct AttrAnimationExample {
建议:通过系统提供的显式动效API实现上述动效功能。 建议:通过系统提供的显式动效API实现上述动效功能。
```javascript ```typescript
@Entry @Entry
@Component @Component
struct AnimateToExample { struct AnimateToExample {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
反例:使用了Grid来实现一个网格,但是在外层套了3层stack容器,导致组件刷新和渲染耗时长。 反例:使用了Grid来实现一个网格,但是在外层套了3层stack容器,导致组件刷新和渲染耗时长。
```javascript ```typescript
@Entry @Entry
@Component @Component
struct AspectRatioExample { struct AspectRatioExample {
...@@ -38,7 +38,7 @@ struct AspectRatioExample { ...@@ -38,7 +38,7 @@ struct AspectRatioExample {
建议:通过减少冗余的Stack容器嵌套,每个GridItem的组件数比上面少了3个,缩短了组件刷新与渲染耗时。 建议:通过减少冗余的Stack容器嵌套,每个GridItem的组件数比上面少了3个,缩短了组件刷新与渲染耗时。
```javascript ```typescript
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册