Link
用链接样式呈现导航与操作。
实时预览
正在加载预览…
参数配置
全部字段 6
LinkOptions
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.Link(c.Key("link"), t, "View documentation", nui.LinkOptions{Color: nui.ColorDefault, Disabled: false, Active: false}).OnClick(func() { s.Clicks++ })
ui.Textf(c, "Activated %d times", s.Clicks)使用说明
点击链接更新下方计数,比较 Active 和 Disabled 外观。此例只触发本地回调;真实页面跳转或打开外部地址由应用在操作回调中实现。
API 参考
Link
源码func Link(c *ui.Context, t Theme, label string, opts LinkOptions) ui.ElementLinkOptions
源码type LinkOptions struct {
URL string
Color Color
Active, Disabled bool
Decoration
}| 字段 | 类型 | 说明 |
|---|---|---|
URL | stringGo 零值: | 打开的外部链接地址。 |
Color | ColorGo 零值: | 语义颜色;默认值继承主题或组件配色。 |
Active | boolGo 零值: | 控制激活状态或动态效果是否运行。 |
Disabled | boolGo 零值: | 禁用组件及其交互。 |
UI | StylesGo 零值: | 以部件名称为键覆盖外观和间距。 |
Style | func(Slot, ui.Element)Go 零值: | 同步配置当前构建的部件;不要保留 Element。 |