【发布时间】:2020-04-26 08:51:42
【问题描述】:
我一直在使用此代码,但一直收到此错误:“无法推断通用参数“C0””此外,它在我的HStack 当我包含这行代码时:
self.userData.tempBatchUnit = productName
我不知道为什么。没有那行代码,代码可以正常工作。非常感谢
struct enterProductUnitView: View {
@EnvironmentObject var userData: UserData
@State var productName: String = ""
var body: some View {
VStack {
HStack { // error Generic parameter 'C0' could not be inferred
Text("Product Unit:")
.font(.headline)
Spacer()
NavigationLink(destination: InstructionsView(desireInstructions: "Product Unit")) {
Text("?")
}
}
Text("ex: bags of popcorn, jars of jam etc.")
.font(.subheadline)
TextField("Enter here", text: $productName)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding()
.padding(.leading)
self.userData.tempBatchUnit = productName
}
}
}
【问题讨论】: