【发布时间】:2021-05-23 14:41:28
【问题描述】:
我正在尝试将 fileurls 数组绑定到 NavigationLink 列表我有一个错误
无法将 'Binding' 类型的值转换为预期参数 输入“范围”
struct ContentView: View {
@State private var fileUrls:[URL] = []
func listDir(dir: String) -> [URL] {
// list file from directory
}
var body: some View {
NavigationView {
ZStack {
VStack {
List{
ForEach($fileUrls) { object in
NavigationLink(destination: PDFKitView(url: self.fileUrl1), isActive: $viewLocalPDF) {
Button("Swift Style"){
self.viewLocalPDF = true
}.padding(.bottom, 20)
}
}
}
}
.navigationBarTitle("Bookshelv ", displayMode: .inline).onAppear {
fileUrls = listDir(dir: "pdfs")
}
}
}
}
【问题讨论】: