1
我有以下的ClojureScript代碼,我試圖檢測點擊的座標。到目前爲止,我甚至無法通過Javascript提醒來識別點擊,更不用說給我一些幫助。檢測點擊座標Clojure
我知道我將不得不編寫一個函數讓它給我確切的細胞被點擊,但作爲一個開始,需要知道如何獲得點擊在頁面上的任何區域的座標。
謝謝!
(defn header [color text]
[:h1
{:style
{:color color
:background-color "blue"}}
text])
(defn Cell []
[:div
{:style
{:width "40px"
:height "40px"
:float "right"
:margin-bottom "1px"
:margin-right "1px"
:background-color "grey"
:border "1px" "solid" "white"}}])
(defn home-page []
[:div
[header "red" "Minesweeper"]
[:div
{:style
{:width "440px"
:height "440px"}}
(repeat 100 [Cell])]])
謝謝克里斯,但我得到一個錯誤,說使用未聲明的Var cljs-minesweeper.core/getClientPosition。 –
好吧,我試着將它切換到(js/getClientPosition),並且錯誤消失了,但現在我得到了「使用未聲明的Var cljs-minesweeper.core/e」 –
哦,對不起,我誤解了你的指示。讓我試試看! –