1

我有一个关于条件和 Hoplon 的问题。当我尝试:

(defn mouse-enter
  [temp stuff]
  (reset! temp @stuff)
  (if (= "y" "y")
      (reset! mon-width {:width "0%"})))

它将 CSS 宽度属性更改为 0,但是,如果我尝试以任何方式使用单元格,它似乎不起作用。IE。

(def week-view (cell "y"))
(def mon-width (cell {:width "50.333%"}))

(defn mouse-enter
  [temp stuff]
  (reset! temp @stuff)
  (if (= "y" (cell= week-view))
      (reset! mon-width {:width "0%"})))

或者:

(defn mouse-enter
  [temp stuff]
  (reset! temp @stuff)
  (if (= "y" (str (cell= week-view)))
      (reset! mon-width {:width "0%"})))

或者:

 (defn mouse-enter
   [temp stuff]
   (reset! temp @stuff)
   (when (= "y" (str (cell= week-view)))
         (reset! mon-width {:width "0%"})))

或者:

 (defn mouse-enter
   [temp stuff]
   (reset! temp @stuff)
   (when (= (cell= "y") (cell= week-view))
         (reset! mon-width {:width "0%"})))

即使 week-view 的值发生了变化,这个也是有效的。

(def week-view (cell "n"))
(def mon-width (cell {:width "50.333%"}))

(defn mouse-enter
  [temp stuff]
  (reset! temp @stuff)
  (when (= (str (cell= "y")) (str (cell= week-view)))
        (reset! mon-width {:width "0%"})))

我真的不知道发生了什么,但我只是想在“周视图”设置为“y”时让真正的条件激活。我尝试了布尔值,这似乎没有用,还有很多其他的东西。

干杯,马特

4

1 回答 1

2

我想我想通了。您可以使用@ 符号来获取单元格的值。这是有效的新代码。

(def week-view (cell nil))
(def mon-width (cell {:width "8.333%"}))

(defn mouse-enter
  [temp stuff]
  (reset! temp @stuff)
  (when (= nil @week-view)
        (reset! mon-width {:width "30%"})))

干杯,马特

于 2017-08-11T06:43:19.520 回答