mirror of
https://github.com/metosin/reitit.git
synced 2025-12-20 01:21:11 +00:00
Polish example
This commit is contained in:
parent
56ad6a5168
commit
0b9c72ab0f
1 changed files with 26 additions and 25 deletions
|
|
@ -19,7 +19,7 @@
|
||||||
[:button
|
[:button
|
||||||
{:type "button"
|
{:type "button"
|
||||||
:on-click #(rfe/replace-state ::item {:id 4})}
|
:on-click #(rfe/replace-state ::item {:id 4})}
|
||||||
"Replace State Item 4"] ])
|
"Replace State Item 4"]])
|
||||||
|
|
||||||
(defn about-page []
|
(defn about-page []
|
||||||
[:div
|
[:div
|
||||||
|
|
@ -52,24 +52,25 @@
|
||||||
[:pre (with-out-str (fedn/pprint @match))]])
|
[:pre (with-out-str (fedn/pprint @match))]])
|
||||||
|
|
||||||
(def routes
|
(def routes
|
||||||
(rf/router
|
[["/"
|
||||||
["/"
|
|
||||||
[""
|
|
||||||
{:name ::frontpage
|
{:name ::frontpage
|
||||||
:view home-page}]
|
:view home-page}]
|
||||||
["about"
|
|
||||||
|
["/about"
|
||||||
{:name ::about
|
{:name ::about
|
||||||
:view about-page}]
|
:view about-page}]
|
||||||
["item/:id"
|
|
||||||
|
["/item/:id"
|
||||||
{:name ::item
|
{:name ::item
|
||||||
:view item-page
|
:view item-page
|
||||||
:parameters {:path {:id s/Int}
|
:parameters {:path {:id s/Int}
|
||||||
:query {(s/optional-key :foo) s/Keyword}}}]]
|
:query {(s/optional-key :foo) s/Keyword}}}]])
|
||||||
{:data {:coercion rsc/coercion}}))
|
|
||||||
|
|
||||||
(defn init! []
|
(defn init! []
|
||||||
(rfe/start! routes
|
(rfe/start!
|
||||||
|
(rf/router routes {:data {:coercion rsc/coercion}})
|
||||||
(fn [m] (reset! match m))
|
(fn [m] (reset! match m))
|
||||||
|
;; set to false to enable HistoryAPI
|
||||||
{:use-fragment true})
|
{:use-fragment true})
|
||||||
(r/render [current-page] (.getElementById js/document "app")))
|
(r/render [current-page] (.getElementById js/document "app")))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue