Jade : if then 的简短版本
Jade : Short version of if then
我有这个有效的代码
if (activePage === 'index')
a.active(href="index.html") Index
else
a(href="index.html") Index
我想用类似的东西来缩短它:
- var vclass = #{activePage==='popol' ? 'active' : ''};
a(class=#{vclass}) Index
或更好的类似
a(class=#{activePage==='index' ? 'active' : ''}) Index
我认为这段代码应该可以工作并且更好
a(href='index.html' class=activePage === 'index' ? 'active' : '') Index
我有这个有效的代码
if (activePage === 'index')
a.active(href="index.html") Index
else
a(href="index.html") Index
我想用类似的东西来缩短它:
- var vclass = #{activePage==='popol' ? 'active' : ''};
a(class=#{vclass}) Index
或更好的类似
a(class=#{activePage==='index' ? 'active' : ''}) Index
我认为这段代码应该可以工作并且更好
a(href='index.html' class=activePage === 'index' ? 'active' : '') Index