Post

Replies

Boosts

Views

Activity

Is anyone can tell me where is wrong that my wrote?
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​:sob:
2
0
25
5h
Is anyone can tell me where is wrong that my wrote?
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​:sob:
Replies
2
Boosts
0
Views
25
Activity
5h