我无法在Domina的touchstart活动中获得'touch'或'changedTouches'列表.
这是我的:需要的东西:
(ns myproj
(:require-macros [hiccups.core :as h])
(:require [domina :as dom]
[hiccups.runtime :as hiccupsrt]
[domina.events :as ev]
[cljs.reader :refer [read-string]]
[wsosc :as wo]
[clojure.browser.repl :as repl]
))
Run Code Online (Sandbox Code Playgroud)
这是我的touchstart事件处理程序:
(defn touchstart [evt]
; store event in an atom for repl access
(swap! de (fn [x] evt))
; print something to html to show a result (no console on the phone)
(dom/set-text! (dom/by-id "result") (str "blah" evt))
; hopefully someday extract touch coordinates here.
(let [rct (.getBoundingClientRect (dom/by-id "osccanvas"))
;touchlist1 (get …Run Code Online (Sandbox Code Playgroud) 任何人都可以帮助我理解,这段代码中发生了什么:
(defn- make-edit-mode-container [widget]
(let [input-container (template/node [:input.editable-edit-mode {:type "text"}])
ghandler (goog.events.KeyHandler. input-container)]
(set! (. input-container -gEditableHandler) ghandler)
;; ...
;; ...
input-container))
Run Code Online (Sandbox Code Playgroud)
据我所知,这里声明了一个私有函数,它接受一个widget参数.local-scope变量input-container是一个节点(实际上它是一个dommy.template节点),它是一个HTML <input type="text" class="editable-edit-mode">元素.
我无法理解的是(goog.events.KeyHandler. input-container)(例如,最后一点是做什么goog.events.Keyhandler).
因此,AFAIU (. input-container -gEditableHandler)是会员访问权限,但后来-gEditableHandler来自哪里,破折号意味着什么?
提前致谢.
我想在ClojureScript中转发声明一个函数.的种类
(defn a [] (b))
...
(defn b [] ...)
Run Code Online (Sandbox Code Playgroud)
我认为什么样的作品是(def b nil)在使用前放置,(b)但我想知道是否有"更好"的方式.
我今天正在与Clojure迈出第一步,我遇到了第一个令人困惑的障碍!
我已经构建了一个新的Leiningen(2.5.1)项目,只想运行默认代码,即:
(ns wavescript.core
(:gen-class))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!"))
Run Code Online (Sandbox Code Playgroud)
问题是Lighttable(0.7.2)控制台告诉:
警告:unsigned-bit-shift-right已经引用:命名空间中的''clojure.core/unsigned-bit-shift-right:cljs.core,被替换为:#'cljs.core/unsigned-bit-shift-right
我找到了一些谷歌条目,但没有一个带我进一步.这是关于什么的?
我正在尝试在clojure中编写一个函数,该函数为向量中的每个值调用一个条件; 该函数应返回应用于每个值的条件结果的OR.例如,我有一个向量[1 2 3 4]和一个条件(> = x 3),其中x是向量中的一个元素,那么该函数应该返回true(类似[0 1 0 1]应该返回false).
我写了这个方法
(defn contains-value-greater-or-equal-to-three [values]
(or (for [x values] (>= x 3)))
)
Run Code Online (Sandbox Code Playgroud)
但是对于向量[1 2 3 4],这只是屈服(false false true true); 我想要的是应用于这些值的'或'函数.
我对函数式编程和clojure很陌生,如果我以错误的方式思考这个问题,请告诉我.
我试图了解如何在core.async中制作有状态的传感器.例如,我如何制作一个传感器来计算通道中的元素数量?例如,我想输入要变换为一个取决于它之前的对象数量的计数.
从我所读到的方式去volatile!用于保持换能器内部的状态,但我仍然不确定如何将所有东西放在一起.
我无法理解IFn和fn之间的差异.
你能举个例子吗?
请提供这些功能之间的差异:
(fn? x)
(ifn? x)
Run Code Online (Sandbox Code Playgroud)
他们表现得一样.
我有以下别名
:aliases {
"start-server" ["do" ["ring" "server-headless"]]
"build-site" ["run" "-m" "cjohansen-no.web/export"]
"build-html" ["run" "-m" "cjohansen-no.web/export-pages"]
"build-prod" ["do" ["build-site"] ["cljsbuild" "once" "prod"]]
"build-js" ["do" ["cljsbuild" "auto" "dev" ]]
"watch-stuff" [ "do" ["start-server"] ["auto" "build-html"]]
"build-dev" ["do" ["build-site"] ["build-js"] "watch-stuff" ]
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,我不能运行"build-dev"而不停止在"build-js"中如何并行执行这些任务或者不在以前的任务中暂停?
试图从字符串中读取哈希映射,但如果键是"关键字"类型值,我从cljs.reader/read-string得到错误.从字符串中读取哈希映射的正确方法是什么?
此版本没有关键字工作:
(cljs.reader/read-string (pr-str {1 "a", 1481876814936 "sdafa", 1481876816039 "afdas", 1481876817344 "asdfa", 2 "b"}))
=> {1 "a", 1481876814936 "sdafa", 1481876816039 "afdas", 1481876817344 "asdfa", 2 "b"}
Run Code Online (Sandbox Code Playgroud)
但是这个带有关键字的版本会抛出错误:
(cljs.reader/read-string (pr-str {:1 "a", :1481876814936 "sdafa", :1481876816039 "afdas", :1481876817344 "asdfa", :2 "b"}))
cljs.user=> #object[TypeError TypeError: Cannot read property '0' of null]
TypeError: Cannot read property '0' of null
at cljs$reader$read_keyword (file:///test/resources/public/js/ui-out/cljs/reader.js:681:19)
at cljs$reader$read_delimited_list (file:///test/resources/public/js/ui-out/cljs/reader.js:397:20)
at cljs$reader$read_map (file:///test/resources/public/js/ui-out/cljs/reader.js:466:41)
at cljs$reader$read (file:///test/resources/public/js/ui-out/cljs/reader.js:879:34)
at cljs$reader$read_string (file:///test/resources/public/js/ui-out/cljs/reader.js:911:25)
at eval (eval at figwheel$client$utils$eval_helper (file:///test/resources/public/js/ui-out/figwheel/client/utils.js:143:8), <anonymous>:1:114)
at eval (eval at …Run Code Online (Sandbox Code Playgroud) 我是clojure的新手,需要一些帮助.
在clojurescript中,我使用地图(存储在原子中)建立一个html表格,例如
[{:id 2, :category "Big bang theory", :name "The Big Bang!"}
{:id 3, :category "The big Lebowski", :name "Ethan Coen"}
{:id 4, :category "Chitty Chitty Bang Bang", :name "Roald Dahl"}]
Run Code Online (Sandbox Code Playgroud)
我想创建一个搜索单词的搜索(即"禁止"),并返回一个地图,其中包含在其某个键值中包含该单词(或其中一部分)的条目.
如果是"禁令",它应该返回
[{:id 2, :category "Big bang theory", :name "The Big Bang!"}
{:id 4, :category "Chitty Chitty Bang Bang", :name "Roald Dahl"}]
Run Code Online (Sandbox Code Playgroud)
根据上面的地图,该表只更新了这两个条目.
我发现了一些有趣的解决方案,但它们都集中在一个键(即:类别或:名称)上,而不是地图条目中的所有键.
我认为这试图达到同样的目的,但我认为没有人给出答案.任何帮助表示赞赏:D