Error
解释失败原因并提供重试操作。
实时预览
正在加载预览…
参数配置
全部字段 9
ErrorOptions
Go 代码
Go
// Inside a view; c is *ui.Context, t is nui.Theme.
// Keep s (example state) outside the view. See the complete example.
nui.ErrorView(c.Key("error"), t, nui.ErrorOptions{Status: "404", Title: "Project not found", Description: "This example does not make network requests.", OnRetry: func() { s.Retries++ }})
ui.Textf(c, "Retry attempts: %d", s.Retries)使用说明
点击重试观察计数变化,示例不发起网络请求。ErrorView 展示状态、说明与重试入口;应用在 OnRetry 中启动实际恢复操作。
API 参考
ErrorView
源码func ErrorView(c *ui.Context, t Theme, o ErrorOptions) ui.ElementErrorOptions
源码type ErrorOptions struct {
Status, Title, Description, RetryLabel string
Icon *ui.SVG
OnRetry func()
Actions func(*ui.Context, Theme)
Decoration
}| 字段 | 类型 | 说明 |
|---|---|---|
Status | stringGo 零值: | 状态文字或状态码。 |
Title | stringGo 零值: | 标题文字。 |
Description | stringGo 零值: | 补充说明文字。 |
RetryLabel | stringGo 零值: | 重试操作的文字。 |
Icon | *ui.SVGGo 零值: | 组件使用的 SVG 图标。 |
OnRetry | func()Go 零值: | 请求重试时通知应用的回调。 |
Actions | func(*ui.Context, Theme)Go 零值: | 附加操作或操作区域构建函数。 |
UI | StylesGo 零值: | 以部件名称为键覆盖外观和间距。 |
Style | func(Slot, ui.Element)Go 零值: | 同步配置当前构建的部件;不要保留 Element。 |