import SwiftUI
import Playgrounds
@main struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct AccountView: View{
var body: some View{
Text("111")
}
}
struct ChatView: View{
var body: some View{
Text("222")
}
}
struct ProjectView: View{
var body: some View{
Text("333")
}
}
struct EnvView: View{
var body: some View{
Text("444")
}
}
struct ContentView: View {
var body: some View {
NavigationSplitView {
List{
NavigationLink("Account",value: 1)
NavigationLink("Chat",value: 2)
NavigationLink("Project",value: 3)
NavigationLink("Enviroments",value: 4)
}
} detail: {
NavigationStack{
VStack{
Text("SB")
}
.navigationDestination(for: Int.self) { number in
switch number {
case 1: AccountView()
case 2: ChatView()
case 3: ProjectView()
case 4: EnvView()
default: Text("未知页面")
}
}
}
}
}
}
#Preview {
ContentView()
}
I want to write a sidebar to change pages, I wrote some codes by advices of Deepseek, but it didn't work, it just stay in the VStack under the contentView.
Help me😭