【发布时间】:2021-04-13 10:20:41
【问题描述】:
我有一个LazyVStack
ScrollView {
if #available(iOS 14.0, *) {
LazyVStack {
ForEach(searchViewModel.allUsers, id: \.uid) { user in
VStack {
profileCard(profileURL: user.profileURL, username: user.username, age: user.age, cardWidth: self.cardWidth, country: user.city)
NavigationLink(destination: ProfileDetailedView(userData: user)) {
EmptyView()
}.buttonStyle(PlainButtonStyle())
}.padding(.top,5)
}
}
} else {
// Fallback on earlier versions
}
}
现在NavigationLink 不工作了?
我没有 LazyVStack 的原始代码运行良好(如下)
List {
ForEach(searchViewModel.allUsers, id: \.uid) { user in
VStack {
profileCard(profileURL: user.profileURL, username: user.username, age: user.age, cardWidth: self.cardWidth, country: user.city)
NavigationLink(destination: ProfileDetailedView(userData: user)) {
EmptyView()
}.buttonStyle(PlainButtonStyle())
}.padding(.top,5)
}
}
更新
我在视图顶部使用 NavigationView
【问题讨论】: