Disable does not work for checkbox when using this.props
问题 How do I make this work? <input type="checkbox" id={"delivery-" + this.props.ID} {this.props.disableIt ? 'disabled' : ''} /> I was expecting this code - {this.props.disableIt ? 'disabled' : ''} - to output a 'disabled' attribute, but it throws 'Unexpected token (102:89)'. But if I directly just put a static 'disabled' word in there, it works. 回答1: When using react, disabled it's a prop that you need to set true or false . When you just define the prop without a value, and this prop it's