我的错误消息是:无法将"无法将类型为"(Int(->VStack>'的值转换为预期的参数类型"(_(->_'">
我知道代码的错误位是我在调用getMedia时使用"array[index].docentID"的位置,但我不知道为什么或如何解决。
你能帮忙吗?
这是我的视图代码:
struct weekDataList: View {
let weekDataF = weekDataFunc()
@ObservedObject var MainViews = MainView()
var body: some View {
VStack {
ForEach(array.count, id: .self) { index in
VStack{
Button(action: {MainViews.getMedia(documentId: array[index].documentID)})
{Text(array[index].startDate + "-" + array[index].endDate)}
}
}.position(x:100,y:-100)
}
}
只是通过代码读取,因为正如我所评论的,快照是不可编译的
ForEach(0..<array.count) { index in
^^^^^^^^^^^^^^^ should be range and no id for indexes