if/else:条件渲染
@Entry
@Component
struct ViewA {
@State count: number = 0;
build() {
Column() {
Text(`count=${this.count}`)
if (this.count > 1) {
Text(`count 大于 1`)
}else{
Text(`啥也不是`)
}
}
}
ForEach:循环渲染
//三

本文介绍了在HarmonyOS中如何使用条件渲染(if/else)和ForEach循环进行组件渲染,以及当数据量过大时如何利用List容器组件来优化显示。示例代码展示了如何在结构化组件中实现这些功能。
https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/arkts-rendering-control-ifelse-0000001524177637-V3#section550519414249
最低0.47元/天 解锁文章
4452

被折叠的 条评论
为什么被折叠?



