我使用"lein new compojure-app"创建一个Web项目,hiccup已经导入project.clj:
:dependencies [[org.clojure/clojure "1.8.0"]
[compojure "1.5.2"]
[hiccup "1.0.5"]
我可以看到 jar 文件
我使用 intellij for ide,in home.clj:
(ns ansible.routes.home
(:require [compojure.core :refer :all]
[ansible.views.layout :as layout]
[hiccup.form :refer :all]
))
但是当写:
(form-to [ :post "/"]
Intellij告诉我form-to can't be resolved
,如果我使用它:
[hiccup.form :as hf]
然后写
(hf/
Intellij告诉我我可以使用function:group,input-filed,make-id,make-name,with-group,但没有form-to,但form-to是包hiccup.form中的一个函数
我该如何解决这个问题?
通常,将 :require
与 :refer :all
一起使用被认为是不好的形式,因为它可能会在您不注意的情况下隐藏某些函数。
检查您在home.clj
中需要的任何其他命名空间是否已经具有一个名为 form-to
的函数。尝试使用类似以下内容:
(ns myapp.routes.home
(:require [compojure.core :as cc :refer [defroutes GET]]
[myapp.views.layout :as layout]
[hiccup.form :as hf]))
(defn home []
(layout/common [:h1 "Hello World!"]))
(defroutes home-routes
(GET "/" [] (home)))