9 Star 0 Fork 0

yanshuifeng/repeat_feature_demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ListItemGroupVRepeat.ets 2.71 KB
一键复制 编辑 原始数据 按行查看 历史
denis.pikalov 提交于 2024-06-19 16:31 . Minor comment
// from yeyinglong, 19.06.2024
@Entry
@ComponentV2
struct ListItemGroupRepeat {
@Local message: string = 'Hello World';
@Local arr: Array<number> = []
@Local lanes: number = 1
aboutToAppear(): void {
for (let i = 0; i < 20; i++) {
this.arr.push(i)
}
}
build() {
Column() {
Row() {
Button('列数+1')
.onClick(() => {
this.lanes++
})
Button('列数-1')
.onClick(() => {
if (this.lanes > 1) {
this.lanes--
}
})
}
List() {
ListItemGroup({style:ListItemGroupStyle.CARD}) {
Repeat<number>(this.arr)
.virtualScroll({totalCount:this.arr.length})
.each((item: RepeatItem<number>) => {
ListItem({style:ListItemStyle.CARD}) {
Text("Group:0,Item:" + item.item.toString())
}
.onAppear(()=>{
console.log("LIST_TEST:Group0:onAppear:" + item.item)
})
.onDisAppear(()=>{
console.log("LIST_TEST:Group0:onDisAppear:" + item.item)
})
})
}
.divider({strokeWidth:1, startMargin:12, endMargin:12})
ListItemGroup({style:ListItemGroupStyle.CARD}) {
Repeat<number>(this.arr)
.virtualScroll({totalCount:this.arr.length})
.each((item: RepeatItem<number>) => {
ListItem({style:ListItemStyle.CARD}) {
Text("Group:1,Item:" + item.item.toString())
}
.onAppear(()=>{
console.log("LIST_TEST:Group1:onAppear:" + item.item)
})
.onDisAppear(()=>{
console.log("LIST_TEST:Group1:onDisAppear:" + item.item)
})
})
}
.divider({strokeWidth:1, startMargin:12, endMargin:12})
ListItemGroup({style:ListItemGroupStyle.CARD}) {
Repeat<number>(this.arr)
.virtualScroll({totalCount:this.arr.length})
.each((item: RepeatItem<number>) => {
ListItem({style:ListItemStyle.CARD}) {
Text("Group:2,Item:" + item.item.toString())
}
.onAppear(()=>{
console.log("LIST_TEST:Group2:onAppear:" + item.item)
})
.onDisAppear(()=>{
console.log("LIST_TEST:Group2:onDisAppear:" + item.item)
})
})
}
.divider({strokeWidth:1, startMargin:12, endMargin:12})
}.backgroundColor(0xDCDCDC)
.height('100%')
.width('100%')
.cachedCount(3)
.lanes(this.lanes)
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yan-shuifeng/repeat_feature_demo.git
git@gitee.com:yan-shuifeng/repeat_feature_demo.git
yan-shuifeng
repeat_feature_demo
repeat_feature_demo
master

搜索帮助