我正在使用create-react-app,因此我提取了一个Bootstrap模板进行反应。这是链接https://www.styleshout.com/templates/preview/Sublime10/#about
我将每个部分提取到其标题,关于,家庭,服务,工作和页脚的组件中。但是,导航栏的切换不起作用。
在我的应用程序中,当我单击汉堡包时,它不会切换
这是我的标头组件,所有jQuery,资源和链接都已连接。
import React, { Component } from 'react';
class Header extends Component {
render() {
return (
<header className="s-header">
<div className="header-logo">
<a className="site-logo" href="index.html">
<img src="images/logo.svg" alt="Homepage" />
</a>
</div>
<nav className="header-nav">
<a href="#nav" className="header-nav__close" title="close"><span>Close</span></a>
<h3>Navigate to</h3>
<div className="header-nav__content">
<ul className="header-nav__list">
<li><a className="smoothscroll" href="#home" title="home">Home</a></li>
<li><a className="smoothscroll" href="#about" title="about">About</a></li>
<li><a className="smoothscroll" href="#services" title="services">Services</a></li>
<li><a className="smoothscroll" href="#works" title="works">Works</a></li>
<li><a className="smoothscroll" href="#contact" title="contact">Contact</a></li>
</ul>
<p>Perspiciatis hic praesentium nesciunt. Et neque a dolorum <a href='#0'>voluptatem</a> porro iusto sequi veritatis libero enim. Iusto id suscipit veritatis neque reprehenderit.</p>
<ul className="header-nav__social">
<li>
<a href="#0"><i className="fab fa-facebook"></i></a>
</li>
<li>
<a href="#0"><i className="fab fa-twitter"></i></a>
</li>
<li>
<a href="#0"><i className="fab fa-instagram"></i></a>
</li>
<li>
<a href="#0"><i className="fab fa-behance"></i></a>
</li>
<li>
<a href="#0"><i className="fab fa-dribbble"></i></a>
</li>
</ul>
</div>
</nav>
<a className="header-menu-toggle" href="#nav">
<span className="header-menu-icon"></span>
</a>
</header>
);
}
}
export default Header;
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="stylesheet" href="%PUBLIC_URL%/css/base.css">
<link rel="stylesheet" href="%PUBLIC_URL%/css/vendor.css">
<link rel="stylesheet" href="%PUBLIC_URL%/css/main.css">
<script src="%PUBLIC_URL%/js/modernizr.js"></script>
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<div id="preloader">
<div id="loader" class="dots-jump">
<div></div>
<div></div>
<div></div>
</div>
</div>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script src="%PUBLIC_URL%/js/jquery-3.2.1.min.js"></script>
<script src="%PUBLIC_URL%/js/plugins.js"></script>
<script src="%PUBLIC_URL%/js/main.js"></script>
</body>
</html>
我的目标是单击汉堡包,然后导航栏滑出。请帮助,谢谢。