设置Scroll的flexGrow为1,以占满剩余空间时,scroll的高度会增长超出屏幕范围,不符合预期啊,应该是到屏幕底部
demo代码
@Preview
@Entry({ routeName: RouteName })
@Component
struct PayDemoPage {
scroller: Scroller = new Scroller()
private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
build() {
Column() {
Text("scroll to 10")
.width('90%')
.height(50)
.margin({top: 60})
.backgroundColor(0xFFFFFF)
.borderRadius(15)
.fontSize(16)
.textAlign(TextAlign.Center)
.margin({ top: 10 })
Scroll(this.scroller) {
Column() {
ForEach(this.arr, (item: number) => {
Text(item.toString())
.width('90%')
.height(150)
.backgroundColor(Color.Blue)
.borderRadius(15)
.fontSize(16)
.textAlign(TextAlign.Center)
.margin({ top: 10 })
}, (item: string) => item)
}
}
.scrollable(ScrollDirection.Vertical)
.flexGrow(1)
}.width('100%').height('100%')
}
}
可以将flexGrow替换成layoutWeight解决此问题