ElmのNavigation
from 『基礎からわかるElm』
Browser.applicationを使う
https://guide.elm-lang.jp/webapps/navigation.html
SPAを作るなら↑これをボイラープレートにすると良さそう
Cmd, Subも簡単に使える
#??
Keyってなに?なんのためにある?
Browser.document
Browser.elementとほぼ同じ
タイトルを動的に切り替えることができる
code:elm
type alias Document msg =
{ title : String
, body : List (Html msg)
}
Browser.UrlRequest
code:elm
type UrlRequest
= Internal Url
| External String
内部リンクと、外部リンクやなmrsekut.icon
pushUrl
SPAの感じでページ遷移するやつ
load
リロードっぽい感じでページ遷移するやつ
Url
$ elm install elm/url
docs
code:elm
type alias Url =
{ protocol : Protocol
, host : String
, port_ : Maybe Int
, path : String
, query : Maybe String
, fragment : Maybe String
}
type Protocol = Http | Https
https://matsubara0507.github.io/posts/2018-12-11-detail-elm-url.html
URLのパース
https://guide.elm-lang.jp/webapps/url_parsing.html
#??
Navigationというのはなに? ref
Urlとどっちを使えばいい?
参考
『基礎からわかるElm』 p.179-