swift - 在 swiftUI 中创建表单究竟意味着什么?
问题描述
var body: some View {
Form{
Text("Hello, World")
}
}
在这段代码中,这段代码是什么
Form{ Text("Hello, World") }
方法?这是在创建“结构表单”的实例吗?或者它是创建一个“结构形式”的实例并只是添加一个闭包?还是我必须将其称为函数生成器?
解决方案
它正在调用Form
构造函数
/// A container for grouping controls used for data entry, such as in settings /// or inspectors. /// /// - SeeAlso: `Section`, which can be used to add sections between groups of /// content. @available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *) public struct Form<Content> : View where Content : View { public init(@ViewBuilder content: () -> Content)
所以
Form{ Text("Hello, World") }
相当于
Form.init(content: { () -> Text in
return Text("Hello, World")
})
推荐阅读
- postgresql - Kafka Connect 自动从 Debezium 主题中提取主键
- performance - -XX:-UseContainerSupport 和 -XX:MaxRAMPercentage 是否会自动计算其他 JVM 资源大小?
- deep-learning - 为什么 GAN(生成对抗网络)被称为“隐式”生成网络?
- c# - 从 Azure SAS URI 创建 BlobContainerClient
- reactjs - 单击另一个 div 时删除活动状态
- java - Soap api插入数据请求在Java中不起作用
- r - 保存最后一个值并使用它来计算差异(闪亮的应用程序)
- reactjs - 在功能组件中使用 react-google-maps 获取地图属性?
- sql - Oracle SQL在列中查找子字符串加2个字符并删除子字符串
- python - 不能从网站上刮桌子