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 docsによると、クロスオーバーは非推奨です。さらに、バックエンド/フロントエンド間でコードを共有する場合にのみ必要です。

私が知っている ClojureScript プロジェクトの最も単純な出発点は次のとおりです。

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

空白のページと「Hello world!」が表示されます。JavaScriptコンソールで。

于 2014-04-11T22:23:17.067 に答える