小编Jan*_*och的帖子

无法将“Published<Bool>.Publisher”类型的值转换为预期的参数类型“Binding<Bool>”

尝试编译以下代码时:

class LoginViewModel: ObservableObject, Identifiable {
    @Published var mailAdress: String = ""
    @Published var password: String = ""
    @Published var showRegister = false
    @Published var showPasswordReset = false

    private let applicationStore: ApplicationStore

    init(applicationStore: ApplicationStore) {
        self.applicationStore = applicationStore
    }

    var passwordResetView: some View {
        PasswordResetView(isPresented: $showPasswordReset) // This is where the error happens
    }
}
Run Code Online (Sandbox Code Playgroud)

其中 PasswordResetView 看起来像这样:

struct PasswordResetView: View {
    @Binding var isPresented: Bool
    @State var mailAddress: String = ""
    
    var body: some View {
            EmptyView()
        }
    } …
Run Code Online (Sandbox Code Playgroud)

ios swift swiftui combine

17
推荐指数
4
解决办法
8509
查看次数

标签 统计

combine ×1

ios ×1

swift ×1

swiftui ×1