[英]JavaScript: var {left, …props} = this.props;
It's a special form of destructuring assignment proposed for ES7 (and eagerly implemented in the jsx tools and Babel). 这是为ES7提出的一种特殊形式的解构分配(并且在jsx工具和Babel中热切地实现)。 It creates two variables:
left
, and props
. 它创建了两个变量:
left
和props
。
left
has the value of this.props.left
. left
具有this.props.left
的值。
props
is an object with all of the other properties of this.props
(excluding left
). props
是一个具有this.props
所有其他属性的this.props
( left
除外)。
If you wrote it without destructuring it'd look like this: 如果你在没有解构的情况下编写它,它看起来像这样:
var left = this.props.left;
var props = {};
Object.keys(this.props).forEach(function(key, index){
if (key !== 'left') {
props[key] = this.props[key];
}
}, this);
That's more than a few characters shaved off :-) 这超过了几个字符剃掉了:-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.