【发布时间】:2020-06-12 04:30:59
【问题描述】:
我正在尝试将一些 navigationBarItems 应用到我的视图中,但我收到了这个错误 - Type '() -> Text' cannot conform to 'View'; only struct/enum/class types can conform to protocols
我已经能够将代码简化为这一点。谁知道是什么原因造成的?
struct NewEntry: View {
var body: some View {
NavigationView {
VStack {
Text("Hello World")
}
.navigationBarItems(trailing: {
Text("Hello World")
})
}
}
}
【问题讨论】: