--- order: 0 title: zh-CN: 基本评论 en-US: Basic comment --- ## zh-CN 一个基本的评论组件,带有作者、头像、时间和操作。 ## en-US A basic comment with author, avatar, time and actions. ```tsx import { DislikeFilled, DislikeOutlined, LikeFilled, LikeOutlined } from '@ant-design/icons'; import { Avatar, Comment, Tooltip } from 'antd'; import dayjs from 'dayjs'; import relativeTime from 'dayjs/plugin/relativeTime'; import React, { createElement, useState } from 'react'; dayjs.extend(relativeTime); const App: React.FC = () => { const [likes, setLikes] = useState(0); const [dislikes, setDislikes] = useState(0); const [action, setAction] = useState(null); const like = () => { setLikes(1); setDislikes(0); setAction('liked'); }; const dislike = () => { setLikes(0); setDislikes(1); setAction('disliked'); }; const actions = [ {createElement(action === 'liked' ? LikeFilled : LikeOutlined)} {likes} , {React.createElement(action === 'disliked' ? DislikeFilled : DislikeOutlined)} {dislikes} , Reply to, ]; return ( Han Solo} avatar={} content={

We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.

} datetime={ {dayjs().fromNow()} } /> ); }; export default App; ``` ```css /* tile uploaded pictures */ .comment-action { padding-left: 8px; cursor: 'auto'; } [class*='-col-rtl'] .comment-action { padding-right: 8px; padding-left: 0; } ```