You may use quotes to specify string literals as attributes:
你可以使用引号指定字符串作为属性:
const element = <div tabIndex="0"></div>;
You may also use curly braces to embed a JavaScript expression in an attribute:
你同样可以在一个属性里使用花括号嵌入一段JavaScript语法:
const element = <img src={user.avatarUrl}></img>
Don't put quotes around curly braces when embedding a JavaScript expression in an attribute. Otherwise JSX will treat the attribute as a string literal rather than an expression. You should either use quotes (for string values) or curly braces (for expressions), but not both in the same attribute.
千万别在属性上使用引号去包裹一个嵌入了JavaScript表达式的花括号。这样做JSX会把属性当作字符串而不是一个表达式。你要么使用引号(字符串)或者使用花括号(表达式),都是不要在同一个属性上同时使用他们。