Skeleton

在加载期间保留内容布局。

实时预览

正在加载预览…

参数配置

全部字段 5

SkeletonOptions

Styles · 0

Go 代码

Go
// Inside a view; c is *ui.Context, t is nui.Theme.
nui.Skeleton(c.Key("skeleton"), t, nui.SkeletonOptions{Width: nui.Set(float32(240)), Height: nui.Set(float32(72)), Animate: nui.Optional[bool]{}})

使用说明

修改宽高并切换 Animate,观察加载占位块。Skeleton 不会启动数据请求,应由应用根据加载状态显示;动画还会遵守减少动态效果设置。

API 参考

Skeleton

源码
func Skeleton(c *ui.Context, t Theme, opts SkeletonOptions) ui.Element

SkeletonOptions

源码
type SkeletonOptions struct {
	Width, Height Optional[float32]
	Animate       Optional[bool]
	Decoration
}
字段类型说明
WidthOptional[float32]

Go 零值: unset

宽度,单位为 DIP。

HeightOptional[float32]

Go 零值: unset

高度,单位为 DIP。

AnimateOptional[bool]

Go 零值: unset

控制动画,并遵守系统的减少动态效果偏好。

UIStyles

Go 零值: zero value

以部件名称为键覆盖外观和间距。

Stylefunc(Slot, ui.Element)

Go 零值: nil

同步配置当前构建的部件;不要保留 Element。