更新时间:2023-12-04 21:11:28
我找到了答案.如果你想在回调中显示另一个视图,你应该
I've found the answer. If you want to show another view on callback you should
创建状态 @State var pushActive = false
当 ViewModel 通知登录成功时,将 pushActive
设置为 true
When ViewModel notifies that login is successful set pushActive
to true
func handleSuccessfullLogin() {
self.pushActive = true
print("handleSuccessfullLogin")
}
创建隐藏的NavigationLink
并绑定到那个状态
NavigationLink(destination:
ProfileView(viewModel: ProfileViewModelImpl()),
isActive: self.$pushActive) {
EmptyView()
}.hidden()