【发布时间】:2020-07-01 04:05:17
【问题描述】:
有谁知道为什么ForEach 中的self.indexCount 会给出错误Cannot use mutating getter on immutable value: 'self' is immutable 错误?我可以提供aView 和indexCount,但这不是很方便。我没有改变 indexCount。这是 SwiftUI 错误还是故意的?
struct aView: View {
let array: [[String]]
lazy var indexCount: Int = array[0].count
var body: some View {
VStack {
ForEach(0..<self.indexCount, id: \.self) { index in
Text("Hello World")
}
}
}
}
【问题讨论】: