本文へスキップ

Router

QuickGUI コアのルーティングを QuickGUI UI に投影し、ネストされたレイアウトと上限付きメモリ履歴を提供します。

デモを読み込み中…

#インポート

github.com/egoist/quickgui/go/ui から ui をインポートします。

import (
	"github.com/egoist/quickgui/go/ui"
)

#使い方

func RouterExample() *native.Node {
	return ui.Router(ui.RouterProps{
		InitialPath: "/",
		Routes: []*ui.RouteDeclaration{
			ui.Route(
				"/",
				func() *native.Node {
					return ui.Link(
						ui.LinkProps{Href: "/settings"},
						"Settings",
					)
				},
			),
			ui.Route(
				"/settings",
				func() *ui.Element { return ui.Text("Settings") },
			),
		},
		Fallback: func() *ui.Element { return ui.Text("Page not found") },
	})
}

#構成

  • ui.Router
  • ui.Route
  • ui.Layout
  • ui.Link
  • ui.Outlet

#API リファレンス

項目を展開すると説明と完全なシグネチャが表示されます。ダッシュは宣言に既定値が記載されていないことを示します。

ui.Router(props RouterProps) *native.Node

Router renders the route table's matched chain. Declarations never change after creation.

Routes[]*RouteDeclaration—

Static route declarations built with `ui.Route` and `ui.Layout`.

[]*RouteDeclaration
ソースを見る
InitialPathstring—

Initial destination for the bounded in-memory history.

string
ソースを見る
FallbackComponent—

Content rendered when no route matches.

Component
ソースを見る