【问题标题】:Attempted import error: 'Grid' is not exported from 'react-bootstrap'尝试导入错误:“网格”未从“react-bootstrap”导出
【发布时间】:2020-06-15 03:47:40
【问题描述】:

我收到此错误 我使用 npx-create-react-app 创建了一个新项目,然后按照此处写下的说明进行操作:https://react-bootstrap.github.io/getting-started/introduction 我已经安装了:npm install react-bootstrap bootstrap。 然后把CDN复制到我的index.html

<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link
**rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous"
/>**
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />

然后已经导入:

import React from 'react';
import  {Grid}  from 'react-bootstrap';
import './App.css';

function App() {
  return (
    <div className="container">
        <Grid className ="purchase-card">
          <h1>Hello World</h1>
        </Grid>
    </div>
  );
}

export default App;

我尝试在 Google 上搜索解决方案和导入变体(例如,从“react-bootstrap/Button”导入按钮),但我似乎找不到导致此问题的问题。

【问题讨论】:

  • Grid 甚至是 react-bootstrap 组件吗?我在文档中没有看到对它的任何引用?
  • 这可能是你的问题:grid was renamed to container

标签: reactjs react-bootstrap


【解决方案1】:

Grid 重命名为 Container as you can see here

【讨论】:

    【解决方案2】:

    而不是使用网格。使用 Container 希望对您有所帮助!

    【讨论】:

      【解决方案3】:

      网格不起作用我尝试了几次.. 您可以使用 Container

      import Container from 'react-bootstrap/Container'
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-03-06
        • 2019-06-06
        • 2019-10-24
        • 2021-10-20
        • 2019-12-19
        • 2023-03-11
        • 1970-01-01
        相关资源
        最近更新 更多