gpt4 book ai didi

javascript - React-bootstrap Navbar 品牌 Logo 未呈现

转载 作者:行者123 更新时间:2023-12-05 01:10:36 39 4
gpt4 key购买 nike

我正在尝试使用 React Bootstrap 在我的 React 应用程序上创建一个与导航栏一起使用的 Logo ,并且我使用了 documentation as a guide .但是,当使用localhost://3000查看页面时,显示如下: App logo not showing

我做错了什么?我什至尝试将示例代码片段从文档站点复制到我的项目中,并且呈现相同的内容。但是,我在 Chrome 本身中打开 svg 文件没有任何问题。这是我的 App.js 代码:

import React from 'react';
import './App.css';
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";
import Container from 'react-bootstrap/Container'
import Navbar from 'react-bootstrap/Navbar';
import Nav from 'react-bootstrap/Nav';

class App extends React.Component {
constructor(props) {
super();
this.state = {
title: "Danny's Website",
headerLinks: [
{ title: 'Home', path: '/' },
{ title: 'Projects', path: '/projects' },
{ title: 'Documents', path: '/documents' },
{ title: 'Contact Me', path: '/contact' }
],
home: {
title: 'Hey there!',
subtitle: 'Welcome to my personal website.',
text: 'Placeholder text for now',
},
projects: {
title: 'My Projects',
subtitle: "From app development to tinkering with robots, I've tried it all",
},
documents: {
title: 'So you wanna see my deets, huh?',
},
contact: {
title: "Let's get in touch",
}

}
}

render() {
return (
<Router>
<Container fluid={true} className='p-0'> { /*Fluid false = Huge left margin. Change padding via "className='p-0'" */}
<Navbar expand="lg" bg="light" variant="light" className="border-bottom">
<Navbar.Brand href="#home" >
<img
alt=""
src="/bootstrap-solid.png"
width="30px"
height="30px"
className="d-inline-block align-top"/>{' '}
Home Site
</Navbar.Brand>
<Navbar.Toggle className="border-0" aria-controls="navbar-toggle" />
<Navbar.Collapse id="navbar-toggle">
<Nav className="ml-auto">
<Link className="nav-link" to="/">Home</Link>
<Link className="nav-link" to="/projects">Projects</Link>
<Link className="nav-link" to="/documents">Documents</Link>
<Link className="nav-link" to="/contact">Contact Me</Link>
</Nav>
</Navbar.Collapse>
</Navbar>
</Container>
</Router>

);
}

}

export default App;

最佳答案

import Logo from '../../images/telcomlogo.jpg';  //  src/images


<Navbar.Brand >
<Link to="/home">
<img width="70px" height="auto" className="img-responsive" src={Logo} alt="logo" />

</Link>
</Navbar.Brand>

关于javascript - React-bootstrap Navbar 品牌 Logo 未呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63979946/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com