【发布时间】:2020-09-21 08:54:30
【问题描述】:
我什至尝试过import {Table} from 'reactstrap';,即使用花括号。当与花括号一起使用时,数据即将到来,但不是作为表格。我的 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
-
是的,错误消失了,但表格仍然不存在。只是数据。我知道这是引导程序的问题。非常感谢
标签: reactjs import export version reactstrap