本文介绍了翡翠复选框根据条件(如果)取消选中属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何让翡翠根据条件渲染复选框的checked属性?
像这两个版本的HTML复选框标签一样:

How do I get jade to render the checked attribute of a checkbox based on a conditional?Like these two versions of the HTML checkbox tag:

这似乎是没有选中的唯一有效版本:

This seems to be the ONLY valid version of unchecked:

>  <input type="checkbox" name="vehicle" value="Bike">


这是检查:

> <input type="checkbox" name="vehicle" value="Car" checked="checked">


这是我迄今为止所尝试的:

Here is what I've tried so far:

这个玉很好:

    input(type="checkbox", name="completed", checked=(true===true ? "checked" : "")).checkbox

因为它呈现:

<input type="checkbox" name="completed" checked="checked" class="checkbox">

但是这个玉不行:

    input(type="checkbox", name="completed", checked=(false===true ? "checked" : "")).checkbox

因为它呈现:

而不是这样:

如何让Jade渲染整个检查属性,而不是只检查attibute的值?

How do I get Jade to render the entire checked attribute instead of just the value of the checked attibute?

推荐答案

您可以使用:

input(type="checkbox", name="completed", checked=(true===false ? "checked" : undefined))

这篇关于翡翠复选框根据条件(如果)取消选中属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 01:49
查看更多