用两个大括号:反应:使用大括号和忽略它们有什么不同吗?
<div theBestProp={"diagonal-texture"}> ...
VS无大括号:
<div theBestProp="diagonal-texture"> ...
同样的问题是相关的 “裁判” 道具:
用两个大括号(来自阵营的文档),访问通过this._input:
<div ref={(c) => this._input = c} ...
VS没有大括号,访问通过this.refs.commander:
<div ref="commander"> ...
我也注意到,一切都出来为字符串。对于这一点:
<PriceOption id="1" yes="true" price="free" audience="for individuals" plan="Starter" />
道具将是(所有字符串):
{
"id": "1",
"yes": "true",
"price": "free",
"audience": "for individuals",
"plan": "Starter"
}
所以我想只能通过布尔值和数字的方式如下:
<PriceOption id={1} yes={true} price="free" audience="for individuals" plan="Starter" />
吧?
嗯,是的..它可能有助于认为PriceOption = {id:1,price:“free”},它是PriceOption是一个具有属性的对象。 (这被称为道具的原因) – vdj4y