Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 pugjs mixin。在 json 上循环创建单选按钮。正常的名称-值对按预期工作。在循环中,将单选按钮设置为默认选中是可以的。试图弄清楚如何不为未选中的单选按钮设置选中的值。
我可以用 javascript 做到这一点,但似乎我应该能够在哈巴狗中做到这一点。
尝试设置变量
-checked =(!fVar.checked)?'checked':''
然后在标签中使用
input(type='radio' #{checked})
有没有办法在哈巴狗中做到这一点?
想出了一个办法。不像我想要的那样直接,但我嵌套了 mixins。主 mixin 有一个调用子 mixin 的 case 语句。
case fVar.checked when 'true' +radioChecked() when 'false' +radioUnchecked()
不是很干,但它有效。