用动作调用 SwiftUI 按钮?

Calling SwiftUI button with action?

我有一个这样的结构。如何调用带动作的 SwiftUIButton?

struct SwiftUIButton: View{
        let action: () -> ()
        var body: some View{
            Button(action: action){Text("Tap me")}
        }
    }

在这里

    SwiftUIButton {
        // do anything here
        print(">> button tapped")
    }

相同(但变体较短)
    SwiftUIButton(action: {
        // do anything here
        print(">> button tapped")
    })