LIST组件
list组件由 list 和 listitem 组成
父子组件
子组件
子组件导出
子组件链接
用link链接
父组件
父组件链接
用state 子组件部分用美元符号修饰
父组件导入
循环渲染
For循环
通过循环渲染(ForEach)从数组中获取数据,并为每个数据项创建相应的组件,可减少代码复杂度。
ForEach(
arr: any[],
itemGenerator: (item: any, index?: number) => void,
keyGenerator?: (item: any, index?: number) => string
)
if-else循环
Column() {
if (this.count < 0) {
Text('count is negative').fontSize(14)
} else if (this.count % 2 === 0) {
Text('count is even').fontSize(14)
} else {
Text('count is odd').fontSize(14)
}
}