我有个笨蛋
?- rad_deg(X,15),sin(X,R,0.0001).
X = 0.2617993877991494,
R = 0.2588088132736575.
?- rad_deg(X,15),R0 is sin(X).
X = 0.2617993877991494,
R0 = 0.25881904510252074.
如何将其作为环境对象传递给SubView?
答案 0 :(得分:1)
您需要创建一个ObservableObject:
class Model: ObservableObject {
@Published var isDragging: Bool = false
}
然后使用:
struct MyView: View {
@EnvironmentObject var mymodel: Model
var body : some View {
if mymodel.isDragging { ... }
}
}
而且,您还应该观看WWDC 2019会议“ Swift中的数据流”。尽管此后更改了一些类型名称,但概念保持不变。