我没有正确导入引导程序,我也不知道为什么。
我运行npm save bootstrap并将文件导入到我的index.js文件中, 每个文档。样式仍然不适用。
Index.js
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import 'bootstrap/dist/css/bootstrap.min.css';
import { BrowserRouter as Router } from "react-router-dom";
ReactDOM.render(
<Router>
<App />
</Router>,
document.getElementById("root")
);
serviceWorker.unregister();
NavBar.js
import React, { Component } from "react";
import { Link } from "react-router-dom";
import logo from "../logo.svg";
export default class Navbar extends Component {
render() {
return (
<nav className="navbar navbar-expand-sm bg-primary navbar-dark px-sm-5">
{/*
https://www.iconfinder.com/icons/1243689/call_phone_icon
Creative Commons (Attribution 3.0 Unported);
https://www.iconfinder.com/Makoto_msk */}
<Link to="/">
<img
src={logo}
alt="store"
className="navbar-brand"/>
</Link>
<ul className=" navbar-nav align-items-center">
<li className="nav-item ml-5">
<Link to="/" className="nav-link">
Products
</Link>
</li>
</ul>
</nav>
);
}
}