尝试导入错误:“reactstrap”不包含默认导出(导入为“表”)

Posted

技术标签:

【中文标题】尝试导入错误:“reactstrap”不包含默认导出(导入为“表”)【英文标题】:Attempted import error: 'reactstrap' does not contain a default export (imported as 'Table') 【发布时间】:2020-09-21 08:54:30 【问题描述】:

我什至尝试过import Table from 'reactstrap';,即使用花括号。当与花括号一起使用时,数据即将到来,但不是作为表格。我的 reactstrap 也是最新版本。 这是显示的错误: 这是我的 Assignment.js。

import Table from 'reactstrap';

class Assignment extends Component

  render()
      return(

     <Table dark>
      <thead>
        <tr>
          <th>#</th>
          <th>First Name</th>
          <th>Last Name</th>
          <th>Username</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th scope="row">1</th>
          <td>Mark</td>
          <td>Otto</td>
          <td>@mdo</td>
        </tr>
        <tr>
          <th scope="row">2</th>
          <td>Jacob</td>
          <td>Thornton</td>
          <td>@fat</td>
        </tr>
        <tr>
          <th scope="row">3</th>
          <td>Larry</td>
          <td>the Bird</td>
          <td>@twitter</td>
        </tr>
      </tbody>
    </Table>

      )
  

导出默认分配;`

【问题讨论】:

5 秒的 google 搜索从 docs 显示,它应该被导入为 import Table from 'reactstrap';。如果你按照你说的那样尝试,你会看到它工作,或者得到一个不同的错误。 Read here 关于命名导入和默认导入之间的区别。 这能回答你的问题吗? using brackets with javascript import syntax 是的,错误消失了,但表格仍然不存在。只是数据。我知道这是引导程序的问题。非常感谢 【参考方案1】:

https://reactstrap.github.io/?path=/docs/home-upgrading--page

移除的组件

InputGroupAddon - This in no longer needed in Bootstrap 5, you can now add Buttons, Inputs directly to InputGroups in the order you wish.
InputGroupButtonDropdown - This can now be replaced with a regular Dropdown component.
CustomInput - These are no longer needed in Bootstrap 5, since all form inputs will be styled by Bootstrap instead of browser default. The existing Input component now supports file, select, switch, and range types.
Jumbotron - Jumbotrons have been removed from Bootstrap 5, can be replaced with <div class="rounded px-3 px-sm-4 py-3 py-sm-5">. Jumbotron fluid can be replaced with <div class="bg-light mb-4 py-3 py-sm-5">

【讨论】:

以上是关于尝试导入错误:“reactstrap”不包含默认导出(导入为“表”)的主要内容,如果未能解决你的问题,请参考以下文章

Gatsby - 警告尝试导入错误:“css”不包含默认导出(导入为“样式”)

./src/index.js 尝试导入错误:“./App.js”不包含默认导出(导入为“App”)

如何修复 Firebase 9.0 导入错误? “尝试导入错误:‘firebase/app’不包含默认导出(导入为‘firebase’)。”

使用 PostCSS 8 的 Gatsby - 尝试导入错误:“component.module.css”不包含默认导出(导入为“样式”)

./src/components/styles.js 尝试导入错误:“@material-ui/core/styles”不包含默认导出(导入为“makeStyles”)

将 reactstrap 与 Next.js 一起使用