首页 > react语法中的...三个点要怎样理解

react语法中的...三个点要怎样理解

初学者,对 {...this.props} 这句很难理解


对象的扩展运算符,我更喜欢叫展开运算符。。。


这不是 React 的语法,这是 ES6 的语法:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator


把数组全部展开。看例子:

var array = [1,2,3,4,5,6,7];
console.log(array);
//输出 [1, 2, 3, 4, 5, 6, 7]
console.log(...array);
//输出 1 2 3 4 5 6 7
【热门文章】
【热门文章】