所以我有这个非常基本的网格。它有 5 列,应该有 3 行。但我不能让编译器编译超过两行的东西......
编译器抱怨:“调用中位置 #11、#12、#13、#14、#15 的额外参数”
如果我删除 Text 6 to 10 它会编译....
代码:
struct ContentView: View {
var columns = [
GridItem(spacing: 8, alignment: .leading),
GridItem(spacing: 8, alignment: .center),
GridItem(spacing: 8, alignment: .center),
GridItem(spacing: 8, alignment: .center),
GridItem(spacing: 8, alignment: .center)
]
var body: some View {
LazyVGrid(columns: columns, spacing: 8) {
Text("Buttons").font(.headline)
Text("resting").font(.subheadline)
Text("active").font(.subheadline)
Text("loading").font(.subheadline)
Text("disabled").font(.subheadline)
Text("1").font(.headline)
Text("2").font(.subheadline)
Text("3").font(.subheadline)
Text("4").font(.subheadline)
Text("5").font(.subheadline)
Text("6").font(.headline)
Text("7").font(.subheadline)
Text("8").font(.subheadline)
Text("9").font(.subheadline)
Text("10").font(.subheadline)
}.padding(.horizontal, 10)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}