es6中为什么要bind(this)
来源:互联网 发布:js有哪些内置对象 编辑:程序博客网 时间:2024/06/01 10:06
在使用React中 如果使用ES6的Class extends写法 如果onClick绑定一个方法 需要bind(this),
而使用react.createClass方法 就不需要.
请问这是为什么呢
解释:React.createClass 是es5的写法默认是绑定了bind方法,而es6中 新增加了class,绑定的方法需要绑定this,如果是箭头函数就不需要绑定this,用箭头的方式
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
阅读全文
0 0
- es6中为什么要bind(this)
- es6中为什么要bind(this)
- ES6 中的 bind(this)
- bind(this)和es6箭头函数
- 关于es6中的arrow function中的this以及bind(this)的比较
- 学习ES6-什么是ES6?为什么要学习ES6?
- ES6中this值为null
- es6箭头函数中this的问题
- es6与es5 中this的区别
- 什么是bind函数,为什么要使用bind函数
- jQuery插件中为什么要return this.each?
- jQuery插件中为什么要return this.each?
- 十,(补充)ES6中箭头函数this的指向
- 方法.bind到某个对象,方法中使用this
- javascript中this,apply,call,bind的学习笔记
- React事件处理函数中绑定this的bind()函数
- $(this).bind("change",itemno_change);
- react系列-bind this
- pdf转word,免费网站
- grafana在login界面白屏(blank screen)及账号密码无法更改
- Codeforces Round #429 (Div 2) A
- 剑指offer——斐波那契数列
- 回文 (dp)
- es6中为什么要bind(this)
- Discuz触屏手机版显示分类信息的修改方法
- 【leetcode】第48题 Rotate Image 题目+解析+代码
- iOS_Runtime4_动态添加属性
- 基于AspectJ的注解方式进行AOP开发
- Axure chrome 扩展显示已损坏的解决方法 写在前面的话: 之前用的好好的Axure chrome 扩展如今却并不能使用,一直说扩展已损坏,额,上网下了几个.crx文件都没有用……
- pygame按键对应
- cube闪烁效果
- JavaBean规范