繁体   English   中英

Clojurescript中带有Hoplon和单元格的条件语句不起作用

[英]Conditional statements in Clojurescript with Hoplon and cells not working

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

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

它将CSS width属性更改为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%"})))

即使周视图的值已更改,此方法也可以工作。

(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”时使真正的条件激活。 我尝试了布尔值,但似乎没有用,还有很多其他东西。

干杯,马特

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

(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%"})))

干杯,马特

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM