你好我有一个项目只需要在超过 30 个项目的循环中显示前 5 个项目,下面是我的代码
struct Introductions: Codable, Identifiable {
let id: String
let topIntros: String?
let image: String
let date: String
}
ForEach(introductions) { introduction in
NavigationLink(destination: IntroductionDetailView(introduction: introduction)) {
IntroductionsView(introduction: introduction)
}
}
我尝试使用这种方法,但是在我滚动过去第五项后,xcode 崩溃了
ForEach(introductions, id: \.topIntros) { introduction in
NavigationLink(destination: IntroductionDetailView(introduction: introduction)) {
IntroductionsView(introduction: introduction)
}
}
谢谢