Avatar
显示用户缩写或图标。
实时预览
正在加载预览…
参数配置
全部字段 8
AvatarOptions
Go 代码
Go
// Inside a view; c is *ui.Context, t is nui.Theme.
nui.Avatar(c.Key("avatar"), t, nui.AvatarOptions{Alt: "Ada Lovelace", Color: nui.ColorDefault, Size: nui.SizeDefault}).AlignSelf(ui.Start)使用说明
输入姓名查看缩写头像,并比较颜色与尺寸。此例通过 Alt 提供姓名;Text 为空时自动显示缩写,显式 Text 则原样显示。图片加载及应用用户资料由应用管理。
API 参考
Avatar
源码func Avatar(c *ui.Context, t Theme, opts AvatarOptions) ui.ElementAvatarOptions
源码type AvatarOptions struct {
Image *ui.Bitmap
Icon *ui.SVG
Text, Alt string
Color Color
Size Size
Decoration
}| 字段 | 类型 | 说明 |
|---|---|---|
Image | *ui.BitmapGo 零值: | 应用持有的位图资源。 |
Icon | *ui.SVGGo 零值: | 组件使用的 SVG 图标。 |
Text | stringGo 零值: | 显示的文字内容。 |
Alt | stringGo 零值: | 图片的替代说明。 |
Color | ColorGo 零值: | 语义颜色;默认值继承主题或组件配色。 |
Size | SizeGo 零值: | 组件尺寸;默认值继承主题或组件尺寸。 |
UI | StylesGo 零值: | 以部件名称为键覆盖外观和间距。 |
Style | func(Slot, ui.Element)Go 零值: | 同步配置当前构建的部件;不要保留 Element。 |