If you use the following code when you want to transition with NavigationLink, you will get an error.Why?
error messages:
Cannot convert value of type 'String' to expected argument type'()->Label'
Current State Code:
struct ContentView:View {
let fruits = ["Apple", "Orange", "Banana"]
varbody:someView {
List{
Section {
Text ("Daikon")
Text ("Cabbage")
Text ("Potato")
} header: {
Text("Yasai")
}
Section {
ForEach(0..<fruit.count) {index in
NavigationLink (destination: AnotherView, label: {Text(fruits[index])})
}
} header: {
Text ("Fruit")
}
}
}
}
structure AnotherView:View {
varbody:someView {
Text ("Text")
destination:AnotherView
part to destination:{AnotherView()}
will not work?
© 2024 OneMinuteCode. All rights reserved.