我在SwiftUI中有一些我不理解的怪异行为,我将其简化为:
struct ContentView: View {
@State var name: String = ""
var body: some View {
Form {
VStack {
Text("Line 1")
Text("Line 2")
Text("Line 3")
Text("Line 4")
Button(action: {
print("hello world")
}) { Text("Print hello world")}
}
}
}
}
这使“第1行” ...“第4行”文本成为“打印问候世界”按钮的一部分。
如果我从窗体中删除VStack,则不会。
我不确定这是否是SwiftUI中的错误,还是不确定我是否应该尝试理解的内容,因此:有人知道为什么行1 ...行4将成为此处按钮的一部分吗?