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

时间:2017-08-10 20:25:21

标签: clojurescript boot-clj hoplon

我对条件和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%"})))

即使周视图的价值发生了变化,这个也有效。

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

我真的不知道发生了什么,但我只是试图在'week-view'设置为“y”时获得真正的条件激活。我试过布尔,似乎没有用,还有很多其他东西。

干杯, 马特

1 个答案:

答案 0 :(得分:2)

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

public class ListExtendConverterJson implements AttributeConverter<Long[], String> {

@Override
public String convertToDatabaseColumn(Long[] list) {
    String result =  JSONArray.toJSONString(list);
    return result;
}

@Override
public Long[] convertToEntityAttribute(String s) {
    List<Long> list = JSONArray.parseArray(s, Long.class);
    Long[] result = new Long[list == null ? 0 :list.size()];
    if(!CollectionUtils.isEmpty(list)) {
        int i = 0;
        for(Long l : list) {
            result[i] = l;
            i ++;
        }
    }
    return result;
}

干杯, 马特