List滚动条时长时短
问题描述:
List滚动条时长时短。
@Entry
@Component
struct ListExample {
private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
private arrItem: string[] = ["我是评论1", "我是评论2", "我是评论3", "我是评论4",
"我是评论5", "我是评论6"]
private arrItem2: string[] = ["我是评论1"]
@Builder
itemList(aa: number) {
List({ space: 20, initialIndex: 0 }) {
if (aa % 2 == 0) {
ForEach(this.arrItem, (item: string) => {
ListItem() {
Text('' + item)
.width('100%')
.height(50)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xFFFFFF)
}
}, (item: string) => item)
} else {
ForEach(this.arrItem2, (item: string) => {
ListItem() {
Text('' + item)
.width('100%')
.height(50)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xFFFFFF)
}
}, (item: string) => item)
}
}
.margin({ left: 20 })
.listDirection(Axis.Vertical)
.scrollBar(BarState.Off)
.width('100%')
}
build() {
Column() {
List({ space: 20, initialIndex: 0 }) {
ForEach(this.arr, (item: number) => {
ListItem() {
Column({ space: 3 }) {
Text('' + item)
.width('100%')
.height(100)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xFFFFFF)
this.itemList(item)
}
}
}, (item: string) => item)
}
.listDirection(Axis.Vertical)
.scrollBar(BarState.On)
.friction(0.6)
.edgeEffect(EdgeEffect.Spring)
.width('90%')
}
.width('100%')
.height('100%')
.backgroundColor(0xDCDCDC)
.padding({ top: 5 })
}
} 1
浏览194 编辑于2024-06-20 03:17北京
全部评论
最多点赞
最新发布
最早发布
写回答
所见即所得编辑器, editor1
工具栏
0/50000
新增插入模板功能
一键使用模板,快速填写内容,轻松发帖~
知道了
- 为了保障您的信息安全,请勿上传您的敏感个人信息(如您的密码等信息)和您的敏感资产信息(如关键源代码、签名私钥、调试安装包、业务日志等信息),且您需自行承担由此产生的信息泄露等安全风险。
- 如您发布的内容为转载内容,请注明内容来源。
我要发帖子
了解社区公约,与您携手共创和谐专业的开发者社区。





































苏公安网备 32011402010933号