我有一个comments具有四个值的对象:
data.js
export const comments = [
{ id: 1, content: 'comment 1', responseTo: 9, writer: 'Max' },
{ id: 2, content: 'comment 2', responseTo: 1, writer: 'John' },
{ id: 3, content: 'comment 2', responseTo: 1, writer: 'John' },
{ id: 4, content: 'comment 2', responseTo: 1, writer: 'John' },
{ id: 6, content: 'comment 3', responseTo: 10, writer: 'Karl' },
{ id: 7, content: 'comment 4', responseTo: 6, writer: 'Tina' },
{ id: 8, content: 'comment 4', responseTo: 6, writer: 'Tina' }
];
App.js
import { comments } from './data';
function App() {
return (
<div>
{comments.map((each) => {
return (
<Fragment>
<Comment each={each} />
</Fragment>
)
);
})}
</div>
);
}
如何在左边显示评论回复?
海绵宝宝撒
相关分类