我在 SwiftUI 项目的引导屏幕中添加了第二个 TabView,并且它抛出了一个错误,错误信息是:“传递给类型为'Int'的参数的尾随闭包不接受闭包”。你有什么想法吗?
TabView {
ForEach(0 ..< onboardingData.count) { index in
let element = onboardingData[index]
OnboardingCard(onboardingItem: element)
}
}
入职卡片:
fileprivate struct OnboardingCard: View {
let onboardingItem: OnboardingItem
var body: some View {
VStack {
Image(onboardingItem.imageName)
.resizable()
.frame(height: 320)
.frame (maxWidth: .infinity)
Text(onboardingItem.title)
.font(.title)
.foregroundColor(.black)
.bold()
.padding()
Text(onboardingItem.description)
.multilineTextAlignment(.center)
.font(.body)
.foregroundColor(.gray)
.padding (.horizontal, 15)
}
}
}
struct OnboardingItem {
let imageName: String
let title: String
let description: String
}
0
后面的空格。 - mahan