【发布时间】:2018-03-10 12:50:04
【问题描述】:
这是我在这个 div 标签中的代码:
<div className="lk-btn-group btn-group clear">
{this.state.invoiceId ? <button className="btn btn-primary btn-sm pull-left" onClick={() => this.printInvoice()}>{abp.localization.localize('PrintInvoice')}</button> : null}
{this.state.delivery.delivery && !this.state.invoiceId ? <button className="btn btn-primary btn-sm pull-left" onClick={() => this.printDeliveryNote()}>{abp.localization.localize('PrintDeliveryNote')}</button> : null}
{this.state.delivery.delivery == null ? <button className="btn btn-primary btn-sm pull-right" onClick={() => {
this.markAsDelivered()
}} disabled={!this.state.beginningPercentage || !this.state.gallonsDelivered}>{this.props.completeDelivery}</button> : <span className="label label-default pull-right"><i className="fa fa-check"></i> {this.props.deliveryComplete}</span>}
</div>
我的问题是如何让输入 0(零)not 与 null 相同?我需要让用户继续输入 0 并让我的禁用按钮 show 而不是 disabled。我相信它发生在上面 div 代码第四行的== null 上,在我看来这禁用了“btn btn-primary btn-sm pull right”
如果用户还没有输入任何内容,那很好,但我还需要将 0 视为输入的任何其他值,而不仅仅是 null 或空,如果这有意义的话。我仍然需要所有其他功能保持不变。
【问题讨论】:
-
0 在 C# 或 JavaScript 中与 null 不同。不完全确定你的意思(显然你知道
==和===是不同的......只是检查) -
它在 c#(asp.net mvc 项目)中,但实际文件是一个 .jsx 文件,它编译成一个 .js 文件。我所知道的是,只要我把 0 放在那里,它仍然会禁用按钮。我试过===无济于事。谢谢!
标签: javascript operators jsx