更新时间:2023-12-05 12:42:04
You better use Knockout's own built-in disable
binding-handler:
<input data-bind="disable: disabled, attr: { name: name, placeholder: placeholder, value: value, type: type }" />
请参见小提琴
或者,您可以检查条件中是否存在明显的真实性",以便如果不满足条件,淘汰赛将删除该属性.例如:
Alternatively, you can check for explicit 'truthfulness' in your condition so that Knockout will remove the attribute if the condition is not met. For example:
<input data-bind="attr: { disabled: disabled() === 'true', ...}" />
请参见此小提琴(在已禁用"输入中键入"true"以激活disabled
).
See this Fiddle (type 'true' in the 'disabled' input to activate disabled
).