Alert.Button 不能转换为 Alert.Button?

Alert.Button is not convertible to Alert.Button?

我尝试向按钮插入一个简单的警报,当我的文本字段为空时,但我收到错误消息 Alert.Button is not convertible to 'Alert.Button?'...

我会说我的代码是 100% 正确的,但是..Xcode 不在我这边..

这是我的代码,..

struct ContentView : View {

@State private var name = String()
@State private var pw = String()
@State private var myAlert = false

var body: some View {
    NavigationView {
        ZStack{
            VStack{
               //deleted code//
                Button(action: {
                    if self.name == self.fileName
                    {
                        print("Hey \(self.name) - your password is \(self.pw)")
                    } else {
                        if self.name.isEmpty && self.pw.isEmpty {
                            self.myAlert = true
                            print("broken!")
                        }
                    }
                    .alert(isPresented: $myAlert) {
                        Alert(title: Text("ERROR!"), message: Text("Username und Password are empty"), dismissButton:.default(Text("Ok")))
                    }
                })
                //deleted code//
}}}}}

有人知道错在哪里吗?我找不到它们。

感谢您的帮助!

1) 没有fileName?

2) 按钮缺少标签:

  Button(action: {...}) {  
  //Label here
}