小编Arj*_*lly的帖子

上下文闭包类型 '() -> Text' 需要 0 个参数,但在闭包主体中使用了 1 个参数

我这里有这个 Swift 代码:

struct chapter: View {
    var body: some View {
        Form {
            ForEach(1..<18) { _ in
                NavigationLink(destination: chapterrun()) {
                    Text("Chapter \($0)")
                }
            }
        }
        .navigationTitle("App")
    }
}
Run Code Online (Sandbox Code Playgroud)

但它给出了错误:

Contextual closure type '() -> Text' expects 0 arguments, but 1 was used in closure body

我该如何解决?

swift swiftui

2
推荐指数
1
解决办法
2574
查看次数

标签 统计

swift ×1

swiftui ×1