Link

用链接样式呈现导航与操作。

实时预览

正在加载预览…

参数配置

全部字段 6

LinkOptions

Styles · 0

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 参考

func Link(c *ui.Context, t Theme, label string, opts LinkOptions) ui.Element

LinkOptions

源码
type LinkOptions struct {
	URL              string
	Color            Color
	Active, Disabled bool
	Decoration
}
字段类型说明
URLstring

Go 零值: ""

打开的外部链接地址。

ColorColor

Go 零值: ColorDefault

语义颜色;默认值继承主题或组件配色。

Activebool

Go 零值: false

控制激活状态或动态效果是否运行。

Disabledbool

Go 零值: false

禁用组件及其交互。

UIStyles

Go 零值: zero value

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

Stylefunc(Slot, ui.Element)

Go 零值: nil

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