如果值设置为0

时间:2017-05-25 10:05:20

标签: reactjs numeric-input

这是我正在渲染的代码:开头的数字输入是空的 - 我想要的,一旦我将它改为数字,例如2,然后将其恢复为0,任何想法如何保持它如果里面没有价值,那么空?

array = ['a', 'b', 'c', 'd']

@observer export default class Widget extends React.Component {

    @observable abc = _.fill([], 0, 0, 27);//[0,0,0,0,0,0] [1,0,0,0,]
    @action changeValueHandler(value, index) {
        this.abc[index] = value;
    }

    render() {

         const abLabels = array.map((curLetter, index) =>
            <div>
                <div>
                    <ControlLabel key={index} value={curLetter} className="letters">{curLetter}</ControlLabel>
                </div>
                <div>
                    <NumericInput key={index} className="numericUpDown" onChange={(value) => this.changeValueHandler(value, index)} precision={0} value={this.abc[index]} step={1} min={0}/>
                </div>
            </div>)

        return (
            <div>
                <ul>{abLabels}</ul>
                <br /><br /><br />
           </div>
        );
    }
}

0 个答案:

没有答案