我一直在尝试让详细视图正常工作,但是当从列表中给出当前所选项目的预览参数时,它一直给我一个错误Cannot convert value of type 'Item.Type' to expected argument type 'Item'
这是详细视图
import SwiftUI
import CoreData
struct FishDetailView: View {
var item: Item
@State var image : Data = .init(count: 0)
var body: some View {
Text(item.title ?? "")
Text(item.details ?? "")
Image(uiImage: UIImage(data: item.imageData ?? self.image)!)
.resizable()
.frame(width: UIScreen.main.bounds.width - 34, height: 210)
.cornerRadius(15)
}
}
struct FishDetailView_Previews: PreviewProvider {
static var previews: some View {
FishDetailView(item: Item) **<--- THE ERROR HAPPENS HERE**
}
}
Run Code Online (Sandbox Code Playgroud)
内容视图.swift
import SwiftUI …Run Code Online (Sandbox Code Playgroud)