react-事件绑定
来源:互联网 发布:mac解压软件哪个好 编辑:程序博客网 时间:2024/05/18 00:45
事件
onClick点击事件
- JSX中,onClick={this.函数名}来绑定事件
- this引用的问题,组件使用ES6写法,需要在构造函数里用bind绑定this,或用箭头函数
改变this的三种方法
1.通过箭头函数
onClick={()=>this.addName()}
2.使用bind绑定this到当前类中
onClick={this.addName.bind(this)
3.在construct构造函数中使用bind
class Register extends React.Component { constructor(props) { super(props) this.login = this.login.bind(this) } login() { ... } render () { return ( <Button onClick={this.login} type='primary'>登录</Button> ) }}
阅读全文
0 0
- react绑定事件
- react-事件绑定
- react 实现双向绑定以及事件绑定
- React中ES6事件绑定相关事项
- react绑定事件的三种方式
- 关于react绑定事件中的this
- React事件处理函数中绑定this的bind()函数
- React学习之事件绑定处理机制(五)
- react合成事件的三种绑定方式bind
- react事件绑定--不再需要bind啦(es6)
- React事件
- react事件
- 绑定事件
- 绑定事件
- 绑定事件
- 事件绑定
- 事件绑定
- 事件绑定
- ArrayList
- model中添加aar的解决方案
- 如何在VSCode中配置python环境
- Book
- 快速排序详解与实现
- react-事件绑定
- linux内核工作队列
- js中call和apply的应用和区别
- oracle对表空间进行操作
- deepmind_lab archlinux官网上面下载的----sudo-1.8.21.p2-1-x86_64.pkg.tar.xz---下载
- .Net网站架构设计(一)架构概念内容
- 时间的格局:让每一分钟为未来增值
- 分布函数
- Eclipse中出现SyntaxError: Non-UTF-8 code starting with '\xc4' in file错误