在react中获取真实dom的时候就需要用到ref属性,具体使用如下
123456789101112131415161718
var MyComponent = React.createClass({ handleClick: function() { console.log(this.input) }, render: function() { return ( <div> <input type="text" ref={(input) => {this.input = input}} /> <input type="button" value="Focus the text input" onClick={this.handleClick} /> </div> ); }});ReactDOM.render( <MyComponent />, document.getElementById('example'));
蓝蜀
我就是个写代码的
杭州
文章
60
分类
8
标签
5
前端 / ant-design-vue踩过的坑
前端 / vue
Update your browser to view this website correctly. Update my browser now
×