this.refs['hh']获取dom对象,this.refs['hh'].value获取dom对象的值

<div id="app"></div>
<script type="text/babel">
var App=React.createClass({
handle:function(e){
e.preventDefault()
console.log(this.refs['hh'].value)
},
render:function(){
return(
<form action="" onSubmit={this.handle}>
<input type="text" defaultValue="hjkhk" ref="hh"/>
<button type="onSubmit">提交</button>
</form>
)
}
});
ReactDOM.render(
<App/>,
document.getElementById("app")
)

posted @ 2018-06-28 09:38  yaomengli  阅读(583)  评论(0编辑  收藏  举报