Spring Boot + Vue健身房管理系统实战:从数据库设计到部署上线
2026/10/8 2:30:26
当需要自定义布局、混合内容或水平/基于网格的滚动时,使用ScrollView搭配LazyVStack、LazyHStack或LazyVGrid。
ScrollView+LazyVStack。ScrollView(.horizontal)+LazyHStack。LazyVGrid;尽可能优先使用自适应列。ScrollViewReader进行滚动到顶部/底部和基于锚点的跳转。safeAreaInset(edge:)。@MainActorstructConversationView:View{privateenumConstants{staticletbottomAnchor="bottom"}@StateprivatevarscrollProxy:ScrollViewProxy?varbody:someView{ScrollViewReader{proxyinScrollView{LazyVStack{ForEach(messages){messageinMessageRow(message:message).id(message.id)}Color.clear.frame(height:1).id(Constants.bottomAnchor)}.padding(.horizontal,.layoutPadding)}.safeAreaInset(edge:.bottom){MessageInputBar()}.onAppear{scrollProxy=proxy withAnimation{proxy.scrollTo(Constants.bottomAnchor,anchor:.bottom)}}}}}ScrollView(.horizontal,showsIndicators:false){LazyHStack(spacing:8){ForEach(chips){chipinChipView(chip:chip)}}}letcolumns=[GridItem(.adaptive(minimum:120))]ScrollView{LazyVGrid(columns:columns,spacing:8){ForEach(items){iteminGridItemView(item:item)}}.padding(8)}Lazy*堆栈。ScrollViewReader时保持 ID 稳定。withAnimation)。List和ScrollView。LazyVStack会带来不必要的复杂性。