Clojurescript 如何在试剂中编辑REITT路由?

Clojurescript 如何在试剂中编辑REITT路由?,clojurescript,reagent,reitit,Clojurescript,Reagent,Reitit,使用默认试剂模板创建的路线如下所示: ;; ------------------------- ;; Routes (def router (reitit/router [["/" :index] ["/items" ["" :items] ["/:item-id" :item]] ["/about" :about]])) 如果我更改一个的路径(“

使用默认试剂模板创建的路线如下所示:

;; -------------------------
;; Routes

(def router
  (reitit/router
   [["/" :index]
    ["/items"
     ["" :items]
     ["/:item-id" :item]]
    ["/about" :about]]))
如果我更改一个的路径(“/about”到“/test”),为什么它不再工作?一定是有别的东西在推动路线,但我似乎不知道是什么

;; -------------------------
;; Routes

(def router
  (reitit/router
   [["/" :index]
    ["/items"
     ["" :items]
     ["/:item-id" :item]]
    ["/test" :about]]))

这是默认的试剂模板(lein new试剂…),我没有更改代码中的任何其他内容。任何帮助都将不胜感激

编辑-一些额外的细节 我在这个函数中(从默认模板中)稍微浏览了一下repl:

我觉得一切都很好。事实上,在repl中执行以下步骤成功地将浏览器导航到正确的页面。但我仍然无法直接输入URL

app:problem.core=> (require '[reitit.frontend :as reitit])
nil
app:problem.core=> (reitit/match-by-path router "/test")
{:template "/test",
 :data {:name :about},
 :result nil,
 :path-params {},
 :path "/test",
 :query-params {},
 :parameters {:path {}, :query {}}}
app:problem.core=> (def match (reitit/match-by-path router "/test"))
#'problem.core/match
app:problem.core=> (:name (:data match))
:about
app:problem.core=> (:path-params match)
{}
app:problem.core=> (def current-page (:name (:data match)))
#'problem.core/current-page
app:problem.core=> (page-for current-page)
#'problem.core/about-page
app:problem.core=> (session/put! :route {:current-page (page-for current-page) :route-params {}})
{:route {:current-page #'problem.core/about-page, :route-params {}}}
app:problem.core=>

看起来您在
src/cljs//core.cljs
中更改了客户端的路由,但在
src/clj//handler.clj
中没有更改服务器端的路由(请查看文件底部附近的
def app

如果您的新客户希望使用Clojure开发web应用程序,我建议您查看,而不是使用试剂模板。这是一个包含更多电池的方法,有更多的文档。《Clojure的Web开发》一书是由同一位作者写的(他也是Regent的贡献者),也是推荐阅读的书

app:problem.core=> (require '[reitit.frontend :as reitit])
nil
app:problem.core=> (reitit/match-by-path router "/test")
{:template "/test",
 :data {:name :about},
 :result nil,
 :path-params {},
 :path "/test",
 :query-params {},
 :parameters {:path {}, :query {}}}
app:problem.core=> (def match (reitit/match-by-path router "/test"))
#'problem.core/match
app:problem.core=> (:name (:data match))
:about
app:problem.core=> (:path-params match)
{}
app:problem.core=> (def current-page (:name (:data match)))
#'problem.core/current-page
app:problem.core=> (page-for current-page)
#'problem.core/about-page
app:problem.core=> (session/put! :route {:current-page (page-for current-page) :route-params {}})
{:route {:current-page #'problem.core/about-page, :route-params {}}}
app:problem.core=>