-1

这是我的代码

struct Home: View {
@State var status = UserDefaults.standard.value(forKey: "status") as? Bool ?? false
var userEmail = Auth.auth().currentUser?.email
@State private var hasTimeElapsed = false

var body: some View {
        if self.status {
            while (idkisrun == true) {
                if group_array.contains(userEmail ?? "1") {
                        HomeScreen()
                    } else {
                        Verify()
                    }
                    }
                    } else {
            VStack{
                Login()
            }

这是错误

    error: closure containing control flow statement cannot be used with result builder 'ViewBuilder'
                while (idkisrun == false) {
                ^
SwiftUI.ViewBuilder:2:30: note: struct 'ViewBuilder' declared here
@resultBuilder public struct ViewBuilder {

我该如何解决这个问题才能等待变量为真,然后从那里继续代码?

4

1 回答 1

0

尝试将“idkisrun”作为已发布变量(如果不是)。比尝试将(while)运算符更改为(if)。它应该有效。此外,“idkisrun”应仅在主线程中更改以更新视图。希望它会有所帮助,祝你好运!)

于 2021-12-24T05:18:01.080 回答