【发布时间】:2021-09-14 00:59:35
【问题描述】:
我在应用程序的前端使用 bootstrap、react 和 nextjs,并尝试使用示例 react-bootstrap 示例 - https://codesandbox.io/s/github/react-bootstrap/code-sandbox-examples/tree/master/basic。结果应该看起来像: 在我看来完全不同:。
我尝试过的事情:
- 从默认引导程序包更改为 bootstrap@next
- 在 index.jsx 文件和 example.jsx 文件中导入 Bootstrap
以下是相关代码: Example.jsx - 与代码和框相同。
import 'bootstrap/dist/css/bootstrap.min.css'
import React, { useState } from 'react'
import Jumbotron from 'react-bootstrap/Jumbotron'
import Toast from 'react-bootstrap/Toast'
import Container from 'react-bootstrap/Container'
import Button from 'react-bootstrap/Button'
const ExampleToast = ({ children }) => {
const [show, toggleShow] = useState(true)
return (
<>
{!show && <Button onClick={() => toggleShow(true)}>Show Toast</Button>}
<Toast show={show} onClose={() => toggleShow(false)}>
<Toast.Header>
<strong className="mr-auto">React-Bootstrap</strong>
</Toast.Header>
<Toast.Body>{children}</Toast.Body>
</Toast>
</>
)
}
const App = () => (
<Container className="p-3">
<Jumbotron>
<h1 className="header">Welcome To React-Bootstrap</h1>
<ExampleToast>
We now have Toasts
<span role="img" aria-label="tada">
????
</span>
</ExampleToast>
</Jumbotron>
</Container>
)
export default App
index.jsx
function HomePage() {
return <div>Welcome to Next.js!</div>
}
export default HomePage
npm list 的结果:
├── bcrypt@5.0.1
├── bootstrap@5.0.0-beta3
├── fastify-cookie@5.3.1
├── fastify-jwt@3.0.0
├── fastify-mongodb@2.0.1
├── fastify-nextjs@5.4.1
├── fastify@3.18.0
├── next@10.2.3
├── nodemon@2.0.7
├── react-bootstrap@1.6.1
├── react-dom@17.0.2
└── react@17.0.2
编辑: 如果我在 index.jsx 中包含引导程序,结果是根本没有应用 css。
【问题讨论】:
标签: css node.js reactjs next.js bootstrap-5