从react.js教程中,我们可以看到双花括号的用法:
<span dangerouslySetInnerHTML={{ __html: rawMarkup }} />
然后在第二个教程“ Thinking in react”中:
<span style={{ color: 'red' }}>
{this.props.product.name}
</span>;
但是,React JSX文档没有描述或提及双花括号。此语法(双curies)的作用是什么?还有另一种方法可以在jsx中表达相同的东西,或者这仅仅是文档中的遗漏?
The exterior set of curly braces are letting JSX know you want a JS expression. The interior set of curly braces represent a JavaScript object, meaning you’re passing in a object to the style attribute.