如何迭代列表中的两个数组:
struct ContentView: View {
let colors = ["red", "green", "blue"]
let names = ["John", "Apple", "Seed"]
var body: some View {
VStack {
List(colors, id: \.self) { color in
Text(color)
}
}
}
}
例如我需要有:
Text("\(color) - \(animal)")
我的代码是这样的(我知道这是错误的,但就是这样):
List(colors, animals id: \.self) { color, animal in
Text("\(color) - \(animal)")
}