diff --git a/zh-cn/application-dev/quick-start/arkts-builder.md b/zh-cn/application-dev/quick-start/arkts-builder.md index 276ee2f8fd48bd2a8bfac77906ceb71204174cd7..dc0df2d9b2c1172534ddccb4acda382d858b9ada 100644 --- a/zh-cn/application-dev/quick-start/arkts-builder.md +++ b/zh-cn/application-dev/quick-start/arkts-builder.md @@ -21,14 +21,14 @@ ```ts -@Builder MyBuilderFunction({ ... }) +@Builder MyBuilderFunction() { ... } ``` 使用方法: ```ts -this.MyBuilderFunction({ ... }) +this.MyBuilderFunction() { ... } ``` - 允许在自定义组件内定义一个或多个自定义构建函数,该函数被认为是该组件的私有、特殊类型的成员函数。 @@ -44,7 +44,7 @@ this.MyBuilderFunction({ ... }) ```ts -@Builder function MyGlobalBuilderFunction({ ... }) +@Builder function MyGlobalBuilderFunction() { ... } ``` 使用方法: @@ -82,7 +82,7 @@ class ABuilderParam { paramB1: string = '' } -ABuilder($$ : ABuilderParam); +@Builder function ABuilder($$ : ABuilderParam) {...} ``` diff --git a/zh-cn/application-dev/quick-start/arkts-declarative-ui-description.md b/zh-cn/application-dev/quick-start/arkts-declarative-ui-description.md index e31bb7049356983368173d97bdb98684edf6b463..41e68029b56746a590f6601fcd6dff065d976453 100644 --- a/zh-cn/application-dev/quick-start/arkts-declarative-ui-description.md +++ b/zh-cn/application-dev/quick-start/arkts-declarative-ui-description.md @@ -116,13 +116,13 @@ Column() { }) ``` -- 使用匿名函数表达式配置组件的事件方法,要求使用bind,以确保函数体中的this指向当前组件。 +- 使用匿名函数表达式配置组件的事件方法,要求使用“() => {...}”,以确保函数与组件绑定,同时符合ArtTS语法规范。 ```ts Button('add counter') - .onClick(function(){ + .onClick(() => { this.counter += 2; - }.bind(this)) + }) ``` - 使用组件的成员函数配置组件的事件方法。 @@ -133,7 +133,7 @@ Column() { } ... Button('add counter') - .onClick(this.myClickHandler.bind(this)) + .onClick(this.myClickHandler) ``` diff --git a/zh-cn/application-dev/quick-start/arkts-rendering-control-lazyforeach.md b/zh-cn/application-dev/quick-start/arkts-rendering-control-lazyforeach.md index ff15b61308f857dfa8e28bbbee475d30a2f4060c..d473dc4bb72720cbaa648e38ddbbc8b6b1e1e063 100644 --- a/zh-cn/application-dev/quick-start/arkts-rendering-control-lazyforeach.md +++ b/zh-cn/application-dev/quick-start/arkts-rendering-control-lazyforeach.md @@ -202,7 +202,7 @@ class MyDataSource extends BasicDataSource { @Component struct MyComponent { aboutToAppear() { - for (var i = 100; i >= 80; i--) { + for (let i = 100; i >= 80; i--) { this.data.pushData(`Hello ${i}`) } } @@ -223,7 +223,7 @@ struct MyComponent { .onClick(() => { this.data.pushData(`Hello ${this.data.totalCount()}`); }) - }, item => item) + }, (item: string) => item) }.cachedCount(5) } } diff --git a/zh-cn/application-dev/quick-start/atomicService-aging.md b/zh-cn/application-dev/quick-start/atomicService-aging.md index c19291c7e2bfdcf43e752d3aa33bbefe820120ba..116a2feb1b77dae8a9d26965546c2c20e286d5a6 100644 --- a/zh-cn/application-dev/quick-start/atomicService-aging.md +++ b/zh-cn/application-dev/quick-start/atomicService-aging.md @@ -17,14 +17,15 @@ ```ts import installer from '@ohos.bundle.installer'; import { BusinessError } from '@ohos.base'; + let bundleName = 'com.ohos.demo'; let installParam: installer.InstallParam = { userId: 100 }; try { - installer.getBundleInstaller().then(data => { - data.uninstall(bundleName, installParam, err => { + installer.getBundleInstaller().then((data: installer.BundleInstaller) => { + data.uninstall(bundleName, installParam, (err: BusinessError) => { if (err) { console.error('uninstall failed:' + err.message); } else {