react监听input框里的值
生活随笔
收集整理的這篇文章主要介紹了
react监听input框里的值
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
import React, { Component } from 'react'
class App extends Component {constructor(props) {super(props)//this.state = {} 定義數據this.state = {inputValue: ""}}render() {return (<div>{/* react里使用表達式,需要用大括號 */}{/* react里綁定事件用駝峰命名,如,onChange */}{/* react里需要改變this的指向,用bind(this) 把this指向到這個標簽里 */}<input type="text" value={this.state.inputValue} onChange={this.change.bind(this)} /></div>
)}change(e) {console.log(e.target.value);//設置數據的值,用this.setState({})this.setState({inputValue: e.target.value})}
}
export default App;
?
轉載于:https://www.cnblogs.com/luguankun/p/11013495.html
總結
以上是生活随笔為你收集整理的react监听input框里的值的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: WPF控件自定义样式(FasContro
- 下一篇: 分表后需要注意的那些事儿