SwiftUI VStack 放多几个组件就报 Argument passed to call that takes no arguments 何解?

2020-01-20 15:07:31 +08:00
 krabs

报错的代码 struct CarInfo: View { @State var showAlert = false var body: some View { VStack{ List { Text("123") //此处报错 Argument passed to call that takes no arguments Text("123") Text("123") Text("123") Text("123") Text("123") Text("123") Text("123") Text("123") Text("123") Text("123") //但是 删除几个 Text 组件后 就没报错 怎么办? } } }

3312 次点击
所在节点    Swift
4 条回复
Sricecake
2020-01-20 15:40:34 +08:00
SwiftUI 一个视图层级不能超过 10 个子视图
krabs
2020-01-20 16:59:33 +08:00
@Sricecake 请问这种情况怎么办?怎么显示多个 Text
cincout
2020-09-18 09:11:36 +08:00
@krabs 包 group
zhentivip
2021-03-16 12:09:51 +08:00
1 、单独写 struct
2 、用 group 抱起来

推荐方案一

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/639451

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX