StateView

@MainActor
public struct StateView : View

SwiftUI状态视图

\@State: 内部值传递,赋值时会触发View刷新 \@Binding: 外部引用传递,实现向外传递引用 \@ObservableObject: 可被订阅的对象,属性标记@Published时生效 \@ObservedObject: View订阅监听,收到通知时刷新View,不被View持有,随时可能被销毁,适合外部数据 \@EnvironmentObject: 全局环境对象,使用environmentObject方法绑定,View及其子层级可直接读取 \@StateObject: View引用对象,生命周期和View保持一致,刷新时数据会保持直到View被销毁

  • Undocumented

    Declaration

    Swift

    @State
    @MainActor
    public var state: ViewState { get nonmutating set }
  • Undocumented

    Declaration

    Swift

    @MainActor
    public init<Content: View>(
        @ViewBuilder content: @escaping (Self, Any?) -> Content
    )
  • Undocumented

    Declaration

    Swift

    @MainActor
    public init<Loading: View, Content: View, Failure: View>(
        @ViewBuilder loading: @escaping (Self) -> Loading,
        @ViewBuilder content: @escaping (Self, Any?) -> Content,
        @ViewBuilder failure: @escaping (Self, Error?) -> Failure
    )
  • Undocumented

    Declaration

    Swift

    @MainActor
    public init<Ready: View, Loading: View, Content: View, Failure: View>(
        @ViewBuilder ready: @escaping (Self) -> Ready,
        @ViewBuilder loading: @escaping (Self) -> Loading,
        @ViewBuilder content: @escaping (Self, Any?) -> Content,
        @ViewBuilder failure: @escaping (Self, Error?) -> Failure
    )
  • Declaration

    Swift

    @MainActor
    public var body: some View { get }