23 lines
557 B
Swift
23 lines
557 B
Swift
import SwiftUI
|
||
|
||
/// 错误占位视图(带重试)。
|
||
public struct ErrorView: View {
|
||
private let message: String
|
||
private let retry: () -> Void
|
||
|
||
public init(message: String, retry: @escaping () -> Void) {
|
||
self.message = message
|
||
self.retry = retry
|
||
}
|
||
|
||
public var body: some View {
|
||
ContentUnavailableView {
|
||
Label("出错了", systemImage: "exclamationmark.triangle")
|
||
} description: {
|
||
Text(message)
|
||
} actions: {
|
||
Button("重试", action: retry)
|
||
}
|
||
}
|
||
}
|