Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
2948a77e
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
提交
2948a77e
编写于
10月 31, 2022
作者:
L
limeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
waterFlow的三个关联属性columnsTemplate、rowsTemplate、layoutDirection的约束关系说明
Signed-off-by:
N
limeng
<
limeng208@huawei.com
>
上级
22b1aa9b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
32 addition
and
5 deletion
+32
-5
zh-cn/application-dev/reference/arkui-ts/ts-container-waterflow.md
...lication-dev/reference/arkui-ts/ts-container-waterflow.md
+32
-5
未找到文件。
zh-cn/application-dev/reference/arkui-ts/ts-container-waterflow.md
浏览文件 @
2948a77e
...
...
@@ -25,7 +25,7 @@ WaterFlow(options?: {footer?: CustomBuilder, scroller?: Scroller})
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ---------- | ----------------------------------------------- | ------ | -------------------------------------------- |
| footer |
[
CustomBuilder
](
ts-types.md#custombuilder8
)
| 否 | 设置WaterFlow尾部组件。 |
| scroller |
[
Scroller
](
ts-container-scroll.md#scroller
)
| 否 | 可滚动组件的控制器,与可滚动组件绑定。 |
| scroller |
[
Scroller
](
ts-container-scroll.md#scroller
)
| 否 | 可滚动组件的控制器,与可滚动组件绑定。
<br/>
目前瀑布流仅支持Scroller组件的scrollToIndex接口。
|
## 属性
...
...
@@ -40,8 +40,21 @@ WaterFlow(options?: {footer?: CustomBuilder, scroller?: Scroller})
| itemConstraintSize |
[
ConstraintSizeOptions
](
ts-types.md#constraintsizeoptions
)
| 设置约束尺寸,子组件布局时,进行尺寸范围限制。 |
| columnsGap | Length |设置列与列的间距。
<br>
默认值:0|
| rowsGap | Length |设置行与行的间距。
<br>
默认值:0|
| layoutDirection |
[
FlexDirection
](
ts-appendix-enums.md#flexdirection
)
|设置布局的主轴方向。|
| layoutDirection |
[
FlexDirection
](
ts-appendix-enums.md#flexdirection
)
|设置布局的主轴方向。
<br/>
默认值:FlexDirection::COLUMN
|
WaterFlow组件的layoutDirection、rowsTemplate和columnsTemplate属性之间的相互关系:layoutDirection优先级高于rowsTemplate和columnsTemplate,设定符合布局方向的Template设置、忽略不符合布局方向的Template设置。根据设置情况,可分为以下三种属性设置模式:
-
layoutDirection设置纵向布局(FlexDirection::COLUMN 或 FlexDirection::COLUMN_REVERSE):
此时,取影响纵向布局的columnsTemplate设置(如果未设置,取默认值),忽略影响横向布局的rowsTemplate设置。例如columnsTemplate设置为"1fr 1fr"、rowsTemplate设置为"1fr 1fr 1fr"时,展示为纵向的,并且辅轴为均分2列的布局。
-
layoutDirection设置横向布局(FlexDirection::ROW 或 FlexDirection::ROW_REVERSE):
此时,取影响横向布局的rowsTemplate设置(如果未设置,取默认值),忽略纵向布局的columnsTemplate设置。例如columnsTemplate设置为"1fr 1fr"、rowsTemplate设置为"1fr 1fr 1fr"时,展示为横向的,并且辅轴为均分3列的布局。
-
layoutDirection未设置布局方向:
此时,布局方向取layoutDirection的默认值:FlexDirection::COLUMN,设定组件为纵向布局。取影响纵向布局的columnsTemplate设置(如果未设置,取默认值),忽略影响横向布局的rowsTemplate设置。例如columnsTemplate设置为"1fr 1fr"、rowsTemplate设置为"1fr 1fr 1fr"时,展示为纵向的,并且辅轴为均分2列的布局。
## 事件
...
...
@@ -79,7 +92,7 @@ export class WaterFlowDataSource implements IDataSource {
private
listeners
:
DataChangeListener
[]
=
[]
constructor
()
{
for
(
let
i
=
0
;
i
<
=
100
;
i
++
)
{
for
(
let
i
=
0
;
i
<
100
;
i
++
)
{
this
.
dataArray
.
push
(
i
);
}
}
...
...
@@ -202,6 +215,8 @@ struct WaterflowDemo {
@
State
colors
:
number
[]
=
[
0xFFC0CB
,
0xDA70D6
,
0x6B8E23
,
0x6A5ACD
,
0x00FFFF
,
0x00FF7F
]
scroller
:
Scroller
=
new
Scroller
();
datasource
:
WaterFlowDataSource
=
new
WaterFlowDataSource
();
private
itemWidthArray
:
number
[]
=
[]
private
itemHeightArray
:
number
[]
=
[]
// 计算flow item宽/高
getSize
()
{
...
...
@@ -209,6 +224,18 @@ struct WaterflowDemo {
return
(
ret
>
this
.
minSize
?
ret
:
this
.
minSize
)
}
// 保存flow item宽/高
getItemSizeArray
()
{
for
(
let
i
=
0
;
i
<
100
;
i
++
)
{
this
.
itemWidthArray
.
push
(
this
.
getSize
());
this
.
itemHeightArray
.
push
(
this
.
getSize
());
}
}
aboutToAppear
()
{
this
.
getItemSizeArray
();
}
@
Builder
itemFoot
()
{
Column
()
{
Text
(
`Footer`
)
...
...
@@ -232,8 +259,8 @@ struct WaterflowDemo {
.
objectFit
(
ImageFit
.
Fill
)
}
}
.
width
(
this
.
getSize
()
)
.
height
(
this
.
getSize
()
)
.
width
(
this
.
itemWidthtArray
[
item1
]
)
.
height
(
this
.
itemHeightArray
[
item1
]
)
.
backgroundColor
(
this
.
colors
[
item
%
5
])
},
item
=>
item
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录