我的工作我的第一個反應過來的分配和運行到一個奇怪的問題。我需要點擊文字有一種形式出現在頁面上。當顯示形式我的尺寸道具16.如果我選擇 - 按鈕的數量將下降到15.如果我選擇+會增加回16問題增加了一些只有減少沒有完成第一
的問題是,當我嘗試和選擇+先按鈕。它會加1,我的電話號碼的末尾,而不是通過增加1數它會顯示161
我的HTML
ReactDOM.render(
<div>
<FontChooser min='4' max='40' size='16' text='Fun with React!' bold='false'/>
</div>,
document.getElementById('container'));
MY JS
class FontChooser extends React.Component {
constructor(props) {
super(props);
this.state = {hidden: 'true', size: this.props.size };
}
handleClick() {
if(this.state.hidden == 'true')
this.setState({hidden: ''});
else
this.setState({hidden: 'true'});
}
decrease() {
this.setState({size: this.state.size -1});
}
increase() {
this.setState({size: this.state.size +1});
}
render() {
return(
<div>
<input type="checkbox" id="boldCheckbox" hidden={this.state.hidden}/>
<button id="decreaseButton" hidden={this.state.hidden} onClick={this.decrease.bind(this)} >-</button>
<span id="fontSizeSpan" hidden={this.state.hidden}>{this.state.size}</span>
<button id="increaseButton" hidden={this.state.hidden} onClick={this.increase.bind(this)} >+</button>
<span id="textSpan" onClick={this.handleClick.bind(this)} >{this.props.text}
</span>
</div>
);
}
}
'parseInt函數(數);' – fungusanthrax