struct SettingsView: View {
var body: some View {
welcomeView()
//:Missing argument for parameter 'currentAuthStat' in call
}
}
struct welcomeView: View {
@Binding var currentAuthStat: UNNotificationSetting
var body: some View {
explanatoryText
}
private var explanatoryText: Text {
let explanatoryText: Text
switch currentAuthStat {
case .enabled:
explanatoryText = Text("Notifications are enabled")
+ Text(Image(systemName: "checkmark"))
default:
explanatoryText = Text("Notifications disabled ")
+ Text(Image(systemName: "x.squareroot"))
}
return explanatoryText
}//: explanatoryText
}
当我尝试在 SettingsView 中显示 welcomeView() 时,我收到错误“调用中的参数 'currentAuthStat' 缺少参数”我尝试将 @State var 添加到 SettingsView 但它给了我一个错误,让我在 ContentView 中进行调用,当我将它添加到 ContentView 它希望我在 App{} @main 页面中添加它,然后我收到错误应用程序不符合 View()。
如何将此解释性文本传递给另一个视图?