0

我一直在命令行中尝试以下操作以使 ClojureScript 运行$ lein cljsbuild auto。但不断收到无法找到交叉的警告:web-viz.x-over。交叉线在我下面的项目中

(defproject web-viz
 :dependencies [[org.clojure/clojure "1.4.0"]
        [ring/ring-core "1.1.7"]
                [ring/ring-jetty-adapter "1.1.7"]
        [compojure "1.1.3"]
        [hiccup "1.0.2"]]
 :plugins      [[lein-ring "0.8.3"]
        [lein-cljsbuild "0.2.10"]]
 :ring         {:handler web-viz.web/app}
 :cljsbuild    {:crossovers [web-viz.x-over],
                 :builds [{:source-paths ["src-cljs"],
                 :crossover-path "xover-cljs",
                 :compiler 
                {:pretty-print true,
                 :output-to "resources/js/script.js",
                 :optimizations :whitespace}}]})

最终,我试图启动并看到这个:

在此处输入图像描述

已创建以下目录:

$ mkdir -p src-cljs/webviz
$ mkdir -p resources/js

还创建了以下文件,src-cljs/webviz/core.cljs其中包含

(ns webviz.core)
    (defn ^:export hello [world]
    (js/alert (str "Hello, " world)))

我的web.clj包含

(defn index-page []
   (html5
     [:head
       [:title "Web Charts"]]
     [:body
       [:h1 {:id "web-charts"} "Web Charts"]
     [:ol
       [:li [:a {:href "/data/census-race.json"} "2010 Census Race Data"]]]
    (include-js "js/script.js")
    (javascript-tag "webviz.core.hello('from ClojureScript!');")]))

(defroutes site-routes
    (GET "/" [] (index-page))
    (route/resources "/")
    (route/not-found "Page not found"))

(def app (-> (handler/site site-routes)))
4

1 回答 1

1

您正在使用一个非常过时的教程。根据Leiningen 文档,不推荐使用交叉。此外,仅当您打算在后端/前端之间共享代码时才需要它们,我怀疑您这样做。

我所知道的 ClojureScript 项目最简单的起点是:

    $ lein new mies webviz && cd webviz
    $ lein cljsbuild once
    $ open index.html

这将为您呈现一个空白页面,以及一个“Hello world!” 在javascript控制台中。

于 2014-04-11T22:23:17.067 回答