Jade条件(if / else)将类添加到div内联 [英] Jade conditional (if/else) to add class to div inline
本文介绍了Jade条件(if / else)将类添加到div内联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if(typeof fromEdit!='undefined')
div#demo.collapse.in
else
div#demo.collapse
想做这个条件检查inline,结果会将.in添加到div的末尾,如果fromEdit存在的话。
解决方案
这样做:
div#demo.collapse(class = typeof fromEdit ===undefined?:in)
尝试一下此处。
Is there a way to do this inline in a jade template?
if(typeof fromEdit != 'undefined')
div#demo.collapse.in
else
div#demo.collapse
Would like to do this conditional check "inline" and the result would add the .in to the end of the div if fromEdit exists.
解决方案
This works:
div#demo.collapse(class=typeof fromEdit === "undefined" ? "" : "in")
Try it out here.
这篇关于Jade条件(if / else)将类添加到div内联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文