我想使用我的Reaction应用程序中的.我使用的是原样给出的例子,但我得到了错误.我能够很好地使用列表和输入法.

ERROR in ./src/components/Idea/CommentsCard.js 142:37-44
export 'Comment' (imported as 'Comment') was not found in 'antd' (possible exports: Affix, Alert, Anchor, App, AutoComplete, Avatar, BackTop, Badge, Breadcrumb, Button, Calendar, Card, Carousel, Cascader, Checkbox, Col, Collapse, ConfigProvider, DatePicker, Descriptions, Divider, Drawer, Dropdown, Empty, FloatButton, Form, Grid, Image, Input, InputNumber, Layout, List, Mentions, Menu, Modal, Pagination, Popconfirm, Popover, Progress, QRCode, Radio, Rate, Result, Row, Segmented, Select, Skeleton, Slider, Space, Spin, Statistic, Steps, Switch, Table, Tabs, Tag, TimePicker, Timeline, Tooltip, Tour, Transfer, Tree, TreeSelect, Typography, Upload, Watermark, message, notification, theme, version)

我已经安装了该程序包

 npm install antd
import { Avatar, Comment, Input, List, Tooltip } from 'antd';


 return (

 
<List
    className="comment-list"
    header={`${data.length} replies`}
    itemLayout="horizontal"
    dataSource={data}
    renderItem={item => (
      <li>
        <Comment
          actions={item.actions}
          author={item.author}
          avatar={ 'https://ui-avatars.com/api/name='+item.author+  '&background=random'}
          content={item.content}
          datetime={item.datetime}
        />
      </li>
    )}
  />

  );

推荐答案

antd的最新版本中没有Comment组件,如果要使用该组件,则需要使用4.x版本

编辑*艾哈迈德是对的,从他的回答来看,有一个可比性方案也应该允许这样做:

import { Comment } from '@ant-design/compatible';

Reactjs相关问答推荐

全局上下文挂钩-替代不起作用

使用useEffect挂钩获取数据

从另一个组件更改组件中const的状态

替换谷歌 map api默认信息窗口与自定义

安装使用环境的BIT组件的依赖项

如何在MUI x图表条形图上放置圆角?

如何在react 中过滤数组的数组?

在 React 中使用forwardRef时无法声明自定义属性

如何在 JS 中绘制具有不同笔画宽度的样条线

如何读取 null 的属性?

使用 map 循环浏览列表列表中的列表并显示它们

如何处理页面加载时发生的 reactjs 错误?

我如何在所有组件中使用 Chakra UI toast?

如何从 graphql/apollo 中的缓存中清除多个查询

React 中的 Slide API Mui 在开始而不是结束时触发侦听器

如何定制 React 热 toastr ?

如何根据react 中的 map 功能一次只打开一个弹出窗口?

ReactJS:按钮启用禁用更改 colored颜色

如何通过 Material Ui 设计将 Accordion 添加到您的 React 项目中?

为什么我从另一个组件收到错误?