In the JSX, is it necessary to specify key on <>? How to?
#14751
Answered
by
ZacharyBear
ZacharyBear
asked this question in
Help/Questions
-
|
Now I'm rendering a table, each data item generates 2 return (
<tbody>
{data.value.map((item) => (
{/* ⬇️ */}
<>
<tr>{/* ... */}</tr>
<tr>{/* ... */}</tr>
</>
}
</tbody>
)This is illegal: map(i => <key={i.id}></>)Should I use the |
Beta Was this translation helpful? Give feedback.
Answered by
ZacharyBear
Apr 23, 2026
Replies: 1 comment
-
|
I found the way to use |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ZacharyBear
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found the way to use
<Fragment />as the root element, so it's able to define the key on it.You can import it from 'vue/jsx-runtime':
import { Fragment } from 'vue/jsx-runtime'