我收到以下错误:
无法将类型“ NavigationLink”的值转换为 关闭结果类型“ _”
你知道这是怎么回事吗?
我的ContentView文件:
@ObservedObject var voucherData = VoucherData()
var body: some View {
NavigationView {
ZStack {
List {
ForEach(voucherData.voucherList) { voucher in
NavigationLink(destination: EditView(value:voucher.value, currency: voucher.currency, shopName: voucher.shopName)) {
VStack() {
在另一个文件中:
struct Voucher : Identifiable {
let id = UUID()
var value : String = ""
var currency : String = ""
var shopName : String = ""
}
final class VoucherData: ObservableObject {
@Published var voucherList: [Voucher] = [
.init(value: "100", currency: "USD", shopName: "FlyBurger")]
}
答案 0 :(得分:0)
我认为您的EditView只是缺少参数凭证:
struct EditView: View {
let voucher: Voucher
...
}
现在,您可以像这样通过凭证:
NavigationLink(destination: EditView(voucher: voucher)) {