2018-10-22 21:20:28 +08:00
|
|
|
---
|
|
|
|
order: 1
|
|
|
|
title:
|
|
|
|
zh-CN: 用法用名单
|
2018-10-29 22:05:42 +08:00
|
|
|
en-US: Usage with list
|
2018-10-22 21:20:28 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
基本评论使用`antd` List组件来呈现一系列注释。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
A basic comment used with `antd` List component to render a series of comments.
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
import { Comment, Icon, Tooltip, List } from 'antd';
|
|
|
|
import moment from 'moment';
|
|
|
|
|
|
|
|
const data = [
|
|
|
|
{
|
2018-10-29 00:26:13 +08:00
|
|
|
actions: [<span>Reply to</span>],
|
2018-10-22 21:20:28 +08:00
|
|
|
author: 'Han Solo',
|
|
|
|
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
|
2018-10-29 00:26:13 +08:00
|
|
|
content: (
|
|
|
|
<p>Nisl nisi scelerisque eu ultrices vitae auctor eu augue. Nulla at volutpat diam ut venenatis tellus in metus vulputate.</p>
|
|
|
|
),
|
2018-10-29 22:05:42 +08:00
|
|
|
time: (
|
|
|
|
<Tooltip title={moment().subtract(1, 'days').format('YYYY-MM-DD HH:mm:ss')}>
|
|
|
|
<span>{moment().subtract(1, 'days').fromNow()}</span>
|
|
|
|
</Tooltip>
|
|
|
|
),
|
2018-10-22 21:20:28 +08:00
|
|
|
},
|
|
|
|
{
|
2018-10-29 00:26:13 +08:00
|
|
|
actions: [<span>Reply to</span>],
|
2018-10-29 22:05:42 +08:00
|
|
|
author: 'Han Solo',
|
2018-10-22 21:20:28 +08:00
|
|
|
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
|
2018-10-29 00:26:13 +08:00
|
|
|
content: (
|
|
|
|
<p>Sed turpis tincidunt id aliquet risus feugiat in ante metus. Faucibus nisl tincidunt eget nullam non.</p>
|
|
|
|
),
|
2018-10-29 22:05:42 +08:00
|
|
|
time: (
|
|
|
|
<Tooltip title={moment().subtract(2, 'days').format('YYYY-MM-DD HH:mm:ss')}>
|
|
|
|
<span>{moment().subtract(2, 'days').fromNow()}</span>
|
|
|
|
</Tooltip>
|
|
|
|
),
|
2018-10-22 21:20:28 +08:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
<List
|
|
|
|
className="comment-list"
|
|
|
|
header={`${data.length} replies`}
|
|
|
|
itemLayout="horizontal"
|
|
|
|
dataSource={data}
|
|
|
|
renderItem={item => (
|
2018-10-24 21:17:37 +08:00
|
|
|
<Comment
|
|
|
|
actions={item.actions}
|
|
|
|
author={item.author}
|
|
|
|
avatar={item.avatar}
|
2018-10-29 00:26:13 +08:00
|
|
|
content={item.content}
|
2018-10-24 21:17:37 +08:00
|
|
|
time={item.time}
|
2018-10-29 00:26:13 +08:00
|
|
|
/>
|
2018-10-22 21:20:28 +08:00
|
|
|
)}
|
|
|
|
/>,
|
|
|
|
mountNode);
|
|
|
|
````
|