我想在按钮元素上动态包含/省略禁用的属性。我已经看到了许多动态属性值的例子,但是没有看到属性本身的例子。我有以下渲染功能:
render: function() {
var maybeDisabled = AppStore.cartIsEmpty() ? "disabled" : "";
return <button {maybeDisabled}>Clear cart</button>
}
This throws a parse error because of the "{" character. How can I include/omit the disabled attribute based on the (boolean) result of AppStore.cartIsEmpty()?