Dev
SwiftUI 页面导航最佳实践
通过全局 Router 1. 定义一个全局 Router 对象,维护页面跳转类型和参数。 @Observable final class Router { public enum Destination: Codable, Hashable { case pageA(models: [Model]) case pageB } var navPath = NavigationPath() func navigate(to destination: Destination) { navPath.append(destination) } func navigateBack() { navPath.removeLast() } func navigateToRoot() { navPath.removeLast(navPath.count) } } 枚举 Destination 可以指