Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
0bc86089
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0bc86089
编写于
8月 31, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 31, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23585 Rectify the arkts syntax of qs
Merge pull request !23585 from 189******51/master
上级
bbdfd303
9c6be93e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
96 addition
and
53 deletion
+96
-53
zh-cn/application-dev/quick-start/arkts-builder.md
zh-cn/application-dev/quick-start/arkts-builder.md
+13
-4
zh-cn/application-dev/quick-start/arkts-builderparam.md
zh-cn/application-dev/quick-start/arkts-builderparam.md
+72
-46
zh-cn/application-dev/quick-start/arkts-create-custom-components.md
...ication-dev/quick-start/arkts-create-custom-components.md
+10
-2
zh-cn/application-dev/quick-start/arkts-extend.md
zh-cn/application-dev/quick-start/arkts-extend.md
+1
-1
未找到文件。
zh-cn/application-dev/quick-start/arkts-builder.md
浏览文件 @
0bc86089
...
...
@@ -77,13 +77,22 @@ MyGlobalBuilderFunction()
```
ts
ABuilder
(
$$
:
{
paramA1
:
string
,
paramB1
:
string
}
);
class
ABuilderParam
{
paramA1
:
string
=
''
paramB1
:
string
=
''
}
ABuilder
(
$$
:
ABuilderParam
);
```
```
ts
@
Builder
function
ABuilder
(
$$
:
{
paramA1
:
string
})
{
class
ABuilderParam
{
paramA1
:
string
=
''
}
@
Builder
function
ABuilder
(
$$
:
ABuilderParam
)
{
Row
()
{
Text
(
`UseStateVarByReference:
${
$$
.
paramA1
}
`
)
}
...
...
@@ -94,10 +103,10 @@ struct Parent {
@
State
label
:
string
=
'
Hello
'
;
build
()
{
Column
()
{
//
在Parent组件中调用ABuilder的时候,将this.label引用传递给ABuilder
//
Pass the this.label reference to the ABuilder component when the ABuilder component is called in the Parent component.
ABuilder
({
paramA1
:
this
.
label
})
Button
(
'
Click me
'
).
onClick
(()
=>
{
//
点击“Click me”后,UI从“Hello”刷新为“ArkUI”
//
After Click me is clicked, the UI text changes from Hello to ArkUI.
this
.
label
=
'
ArkUI
'
;
})
}
...
...
zh-cn/application-dev/quick-start/arkts-builderparam.md
浏览文件 @
0bc86089
...
...
@@ -34,30 +34,34 @@
-
用父组件自定义构建函数初始化子组件
\@
BuildParam装饰的方法。
```
ts
@
Component
struct
Child
{
@
BuilderParam
aBuilder0
:
()
=>
void
;
@
Component
struct
Child
{
@
Builder
componentBuilder
()
{
Text
(
`Parent builder `
)
}
build
()
{
Column
()
{
this
.
aBuilder0
()
}
@
BuilderParam
aBuilder0
:
()
=>
void
=
this
.
componentBuilder
;
build
()
{
Column
()
{
this
.
aBuilder0
()
}
}
}
@
Entry
@
Component
struct
Parent
{
@
Builder
componentBuilder
()
{
Text
(
`Parent builder `
)
}
@
Entry
@
Component
struct
Parent
{
@
Builder
componentBuilder
()
{
Text
(
`Parent builder `
)
}
build
()
{
Column
()
{
Child
({
aBuilder0
:
this
.
componentBuilder
})
}
build
()
{
Column
()
{
Child
({
aBuilder0
:
this
.
componentBuilder
})
}
}
}
```
...
...
@@ -70,36 +74,40 @@
> 开发者谨慎使用bind改变函数调用的上下文,可能会使this指向混乱。
```
ts
@
Component
struct
Child
{
label
:
string
=
`Child`
@
BuilderParam
aBuilder0
:
()
=>
void
;
@
BuilderParam
aBuilder1
:
()
=>
void
;
build
()
{
Column
()
{
this
.
aBuilder0
()
this
.
aBuilder1
()
}
}
@
Component
struct
Child
{
@
Builder
componentBuilder
()
{
Text
(
`Child builder `
)
}
@
Entry
@
Component
struct
Parent
{
label
:
string
=
`Parent`
label
:
string
=
`Child`
@
BuilderParam
aBuilder0
:
()
=>
void
=
this
.
componentBuilder
;
@
BuilderParam
aBuilder1
:
()
=>
void
=
this
.
componentBuilder
;
@
Builder
componentBuilder
()
{
Text
(
`
${
this
.
label
}
`
)
build
()
{
Column
()
{
this
.
aBuilder0
()
this
.
aBuilder1
()
}
}
}
build
()
{
Column
()
{
this
.
componentBuilder
()
Child
({
aBuilder0
:
this
.
componentBuilder
,
aBuilder1
:
this
.
componentBuilder
.
bind
(
this
)
})
}
@
Entry
@
Component
struct
Parent
{
label
:
string
=
`Parent`
@
Builder
componentBuilder
()
{
Text
(
`
${
this
.
label
}
`
)
}
build
()
{
Column
()
{
this
.
componentBuilder
()
Child
({
aBuilder0
:
this
.
componentBuilder
,
aBuilder1
:
this
.
componentBuilder
})
}
}
}
```
...
...
@@ -112,7 +120,11 @@
```
ts
@
Builder
function
GlobalBuilder1
(
$$
:
{
label
:
string
})
{
class
GlobalBuilderParam
{
label
:
string
=
""
}
@
Builder
function
GlobalBuilder1
(
$$
:
GlobalBuilderParam
)
{
Text
(
$$
.
label
)
.
width
(
400
)
.
height
(
50
)
...
...
@@ -121,11 +133,15 @@
@
Component
struct
Child
{
@
Builder
componentBuilder
()
{
Text
(
`Child builder `
)
}
label
:
string
=
'
Child
'
// 无参数类,指向的componentBuilder也是无参数类型
@
BuilderParam
aBuilder0
:
()
=>
void
;
@
BuilderParam
aBuilder0
:
()
=>
void
=
this
.
componentBuilder
;
// 有参数类型,指向的GlobalBuilder1也是有参数类型的方法
@
BuilderParam
aBuilder1
:
(
$$
:
{
label
:
string
})
=>
void
;
@
BuilderParam
aBuilder1
:
(
$$
:
GlobalBuilderParam
)
=>
void
=
this
.
componentBuilder
;
build
()
{
Column
()
{
...
...
@@ -167,10 +183,17 @@ struct Parent {
```
ts
// xxx.ets
class
CustomContainerParam
{
header
:
string
=
''
;
}
@
Component
struct
CustomContainer
{
@
Prop
header
:
string
;
@
BuilderParam
closer
:
()
=>
void
@
Builder
componentCloser
()
{
Text
(
`Custom closer `
)
}
@
Prop
header
:
string
=
''
;
@
BuilderParam
closer
:
()
=>
void
=
this
.
componentCloser
;
build
()
{
Column
()
{
...
...
@@ -194,12 +217,15 @@ struct CustomContainer {
@
Component
struct
CustomContainerUser
{
@
State
text
:
string
=
'
header
'
;
param
:
CustomContainerParam
=
{
header
:
this
.
text
};
build
()
{
Column
()
{
// 创建CustomContainer,在创建CustomContainer时,通过其后紧跟一个大括号“{}”形成尾随闭包
// 作为传递给子组件CustomContainer @BuilderParam closer: () => void的参数
CustomContainer
(
{
header
:
this
.
text
}
)
{
CustomContainer
(
this
.
param
)
{
Column
()
{
specificParam
(
'
testA
'
,
'
testB
'
)
}.
backgroundColor
(
Color
.
Yellow
)
...
...
zh-cn/application-dev/quick-start/arkts-create-custom-components.md
浏览文件 @
0bc86089
...
...
@@ -42,15 +42,23 @@ HelloComponent可以在其他自定义组件中的build()函数中多次创建
```
ts
class
HelloComponentParam
{
message
:
string
=
""
}
@
Entry
@
Component
struct
ParentComponent
{
param
:
HelloComponentParam
=
{
message
:
'
Hello, World!
'
}
build
()
{
Column
()
{
Text
(
'
ArkUI message
'
)
HelloComponent
(
{
message
:
'
Hello, World!
'
}
);
HelloComponent
(
param
);
Divider
()
HelloComponent
(
{
message
:
'
你好!
'
}
);
HelloComponent
(
param
);
}
}
}
...
...
zh-cn/application-dev/quick-start/arkts-extend.md
浏览文件 @
0bc86089
...
...
@@ -81,7 +81,7 @@
build
()
{
Row
({
space
:
10
})
{
Text
(
`
${
this
.
label
}
`
)
.
makeMeClick
(
this
.
onClickHandler
.
bind
(
this
)
)
.
makeMeClick
(
this
.
onClickHandler
)
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录