在React JS中这个关键字之前是什么::? [英] What is :: before this keyword in React JS?
本文介绍了在React JS中这个关键字之前是什么::?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一些react-js库中看到了类似下面的语法。这是什么意思,以及如何帮助我编写代码?
I see some syntax like below in some react-js libraries. What is that mean and how can help me in my codes?
const inputAttributes = {
id: 'events-playground',
placeholder: 'Where are you now?',
onChange: ::this.onInputChanged,
onBlur: ::this.onInputBlurred
};
谢谢。
推荐答案
这是 .bind 的新ES7语法,
等价于ES5
const inputAttributes = {
id: 'events-playground',
placeholder: 'Where are you now?',
onChange: this.onInputChanged.bind(this),
onBlur: this.onInputBlurred.bind(this)
};
这篇关于在React JS中这个关键字之前是什么::?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文