ReactJS中"...... this.props"是什么意思?

Zha*_* Yi 5 javascript ecmascript-6 reactjs

{...this.props}这段代码意味着什么?

<div {...this.props} style={{ height: `100%`, }}
Run Code Online (Sandbox Code Playgroud)

ROA*_*OAL 11

{...variable}语法被称为"传播属性".

它的作用基本上是它采用this.props(或任何其他传递的变量)的每个属性并将它们应用于元素.

例:

props = {className: 'big', href: 'http://example.com'};

<a {...props} />
// the above line is equal to the following
<a className="big" href="http://example.com" />
Run Code Online (Sandbox Code Playgroud)