简体   繁体   English

Figwheel为什么不将编译的应用程序传递给浏览器?

[英]Why doesn't figwheel pass the compiled app to the browser?

I'm using Leiningen 2.5.2 (Java 1.8.0_45-internal Open JDK 64-bit), and the reagent-template (ie lein new reagent foo ). 我正在使用Leiningen 2.5.2(Java 1.8.0_45-内部Open JDK 64位)和试剂模板(即lein new reagent foo )。

This runs okay with lein figwheel as expected. lein figwheel一起运行可以正常进行。

Next, the first thing I do is break out the "Views" functions into separate files and add them to the app namespace: 接下来,我要做的第一件事是将“视图”功能分解为单独的文件,并将它们添加到应用程序名称空间:

core.cljs snippet: core.cljs片段:

;; -------------------------
;; Views

(:require home-page)

home-page.cljs (whole file): home-page.cljs(整个文件):

(ns foo.core)

(defn home-page []
  [:div [:h2 "Welcome to foo"]
   [:div [:a {:href "#/about"} "go to about page"]]])

When I go to view the app in the browser (chromium or firefox), it gets stuck at "ClojureScript has not been compiled!" 当我在浏览器(铬或Firefox)中查看应用程序时,它卡在“ ClojureScript尚未编译!”中。 despite seemingly compiling successfully in the terminal. 尽管似乎在终端中编译成功。 If I enter commands in the figwheel REPL, I see the green Clojure logo when it is working in the browser, so I know it's connected. 如果我在figwheel REPL中输入命令,当它在浏览器中运行时,我会看到绿色的Clojure徽标,因此我知道它已连接。

I had this working in a reagent app some months ago--what happened? 几个月前,我曾在试剂应用程序中进行过这项工作-发生了什么事? How should I separate my view code? 应该如何分隔视图代码? (A single file is unmanageable; that's a lot of Hiccup.) (单个文件无法管理;这是很多麻烦。)

If you really have only the line (:require home-page) in core.cljs, this should be the culprit. 如果您实际上在core.cljs中只有一行(:require home-page) ,那应该是罪魁祸首。 The colon notation :require is only valid inside a namespace declaration with ns . 冒号:require仅在带有ns的名称空间声明内有效。 Also, you declare the core namespace in the wrong file (home-page.cljs, not core.cljs). 另外,您在错误的文件(home-page.cljs,而不是core.cljs)中声明了核心名称空间。 Take a look at this article on namespaces in Clojure for a thorough explanation. 参阅这篇有关Clojure中的名称空间的文章,以获取详尽的解释。

You will want the following in core.cljs: 您将在core.cljs中需要以下内容:

(ns foo.core
  (:require [foo.home-page :as hp :refer [home-page]]))
.... more core.cljs code ...

and then simply in home-page.cljs: 然后只需在home-page.cljs中:

(ns foo.home-page
  (:require ....reagent namespaces as needed ....

(defn home-page [] ....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Figwheel无法在Windows7的试剂项目中启动 - figwheel doesn't start in reagent project on windows7 如何找出为什么编译后的GWT应用程序不初始化但可以在托管模式下工作? - How to find out why compiled GWT app doesn't initialize but works in hosted mode? 为什么 JVM 不缓存 JIT 编译的代码? - Why doesn't the JVM cache JIT compiled code? 为什么小程序不能在浏览器中运行,而不能在IDE中运行? - Why doesn't the applet run in browser but in IDE? 球衣。 为什么参数不通过? - jersey. why doesn't parameter pass? 为什么我的 for 循环不传递值? - Why doesn't my for loop pass values? 为什么getClass()。getProtectionDomain()。getCodeSource()。getLocation()。getPath()在编译后在最终产品中不起作用? - Why getClass().getProtectionDomain().getCodeSource().getLocation().getPath() doesn't work in final product after compiled? 为什么此代码不处理浏览器中的事件? - Why doesn't this code handle events from the browser? 为什么session.invalidate在IE浏览器中不起作用? - Why session.invalidate doesn't work in IE browser? 为什么我的Cucumber步骤类无法打开Firefox浏览器? - Why doesn't my Cucumber step class open Firefox browser?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM