片段可以有属性吗?
Can a fragment have an attribute?
我必须为片段设置一个属性。我想做这样的事情:
<className="name">
abcd
</>
有什么办法可以这样吗?
你不能,因为它是特定于 React 而不是 HTML 标签。 docs 是这样说的:
You can use <></> the same way you’d use any other element except that
it doesn’t support keys or attributes.
我必须为片段设置一个属性。我想做这样的事情:
<className="name">
abcd
</>
有什么办法可以这样吗?
你不能,因为它是特定于 React 而不是 HTML 标签。 docs 是这样说的:
You can use <></> the same way you’d use any other element except that it doesn’t support keys or attributes.