React로 의미 론적 요소를 래핑하여 앱에서 재사용 할 수 있도록 노력 중입니다. 여기ReactJS : 상위 요소에서 하위 구성 요소 속성에 액세스
<form onSubmit={this.handleSubmit} method="POST">
<s_input placeHolder={this.props.placeHolderTxt||''}></s_input>
</form>
그리고 내 handleSubmit 방법이다 : A는에서 내부
var s_input = React.createClass({
render: function(){
return this.transferPropsTo(
<div className = "ui input">
<input type="text" placeholder={this.props.placeHolderTxt} ref="text"/>
</div>
)
}
});
I는 입력 구성 요소를 사용하고
handleSubmit:function(e){
e.preventDefault();
var text = this.refs.text.getDOMNode().value.trim();
this.refs.text.getDOMNode().value = '';
this.props.onSubmit(text);
}
나는 텍스트를 액세스하려고이 문제 재산 입력 구성 요소를 제출할 때 양식을 제출하면과 같은 작업을 수행 할 수 있습니다.. 아무도이 일을하는 법을 알고 있습니다.
'handleSubmit()'메서드를 모두 표시 할 수 있습니까? – cantera
질문을 편집하고 handleSubmit()에 대한 코드를 포함했습니다 – nimgrg