简体   繁体   English

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

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

I have a question regarding conditionals and Hoplon. 我有一个关于条件和Hoplon的问题。 When I try: 当我尝试:

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

It changes the CSS width property to 0, but, if I try using a cell in any way it doesn't seem to work. 它将CSS width属性更改为0,但是,如果我尝试以任何方式使用单元,它似乎都无法正常工作。 IE. 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%"})))

Or: 要么:

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

Or: 要么:

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

Or: 要么:

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

And this one works even though the value of week-view has changed. 即使周视图的值已更改,此方法也可以工作。

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

I don't really know what is going on but I am just trying to get the true conditional active when 'week-view' is set to "y". 我真的不知道发生了什么,但是我只是想在“周视图”设置为“ y”时使真正的条件激活。 I tried booleans, that didn't seem to work and a lot of other stuff. 我尝试了布尔值,但似乎没有用,还有很多其他东西。

Cheers, Matt 干杯,马特

I think I figured it out. 我想我知道了。 You can use the @ symbol to get the value of the cell. 您可以使用@符号获取单元格的值。 Here is the new code that works. 这是有效的新代码。

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

Cheers, Matt 干杯,马特

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

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