如何在 SwiftUI 中从一个视图重定向到另一个视图?

How to redirect from one view to another view in SwiftUI?

我正在使用 SwiftUI。我正在尝试从列表移动到特定列表行的详细信息。我使用了下面写的代码

struct StudentList: View {
    var body: some View {
        NavigationView {
            List(studentData) { student in
                NavigationLink(destination: studentDetail()) {
                    studentRow(student: student)
                }
            }
            .navigationBarTitle(Text("Student Details"))
        }
    }
}

struct StudentList_Previews: PreviewProvider {
    static var previews: some View {
        StudentsList()
    }
}

使用这个

 List(studentData) { student in
     NavigationLink.init("Here Title", destination:  studentDetail())
 }   
struct ContentView: View {

  let items = [1,2,3,4,5]
  var body: some View {

    NavigationView {
      List(items, id: \.self) { inx in
        NavigationLink(destination: DetailsView(inx: inx)) {
            Text("\(inx)")
        }
      }
    }
  }
}

struct DetailsView: View {
    var  inx : Int
    var body: some View {
        VStack {
            Text("\(inx)")
        }
    }
}
 NavigationLink(destination: "provide your view here") {

                    }