【发布时间】:2022-08-18 14:58:10
【问题描述】:
我想知道是否有人可以帮助解释为什么我可能会收到错误:
类型\'()\'不能符合\'View\'
我一直在查看其他一些与错误有类似问题的帖子,但我似乎仍然无法弄清楚。
这是我的代码供参考:
var body: some View { ScrollView (.vertical, showsIndicators: false) { VStack { HeaderComponent() Spacer(minLength: 10) if (!matchSet.mSet.isEmpty) { VStack { //**this is where the error is occurs** matchSet.mSet.forEach { college in CollegeButton(name: college.dest.name) }这里也是 CollegeButton 结构
struct CollegeButton: View { var name: String var body: some View { Button(action: { print(\"You clicked \" + name) }) { Text(name.uppercased()) .modifier(ButtonModifier()) } }}
-
试试Apple SwiftUI Tutorials 你似乎遗漏了一些基本概念