【发布时间】:2020-11-14 16:34:13
【问题描述】:
在我的整个应用程序中,我都在使用到达路由器来处理我的页面之间的导航。
但是,我找到了一个我喜欢的导航栏组件,并将其带入了我的应用程序。我不知道为什么,但是“to:”/profile“”按钮实际上并没有导航和加载我的 http://localhost:3000/profile 页面。
它确实将 html 地址更改为显示 http://localhost:3000/profile,但它不会重定向和加载配置文件页面。我必须刷新浏览器才能这样做。
关于如何让这个“我的个人资料”按钮实际重定向和加载个人资料页面的任何想法?我可以在这种语法中使用到达路由器“导航(/”配置文件“)”吗?当我尝试时,它似乎不适合。谢谢!
Navbar.js
import { BorderStyle } from "@material-ui/icons";
import React from "react";
import * as ReactNavbar from "react-responsive-animate-navbar";
import Logo from "../Assets/Media/ToolioLogoSmall.png"
import { navigate, Link } from "@reach/router"; //not using this currently, but it is used for navigation throughout the rest of my app.
export default function Navbar() {
console.log(ReactNavbar.ReactNavbar)
return (
<div style={style.background}>
<ReactNavbar.ReactNavbar style={style.background}
color="rgb(25, 25, 25)"
logo={Logo}
menu={[
{ name: "HOME", to: "/Explore" },
{ name: "ARTICLES", to: "/articles" },
{ name: "My Profile", to: "/profile" },
{ name: "CONTACT", to: "/contact" },
]}
social={[
{
name: "Linkedin",
url: "https://www.linkedin.com/",
icon: ["fab", "linkedin-in"],
},
{
name: "Facebook",
url: "https://www.facebook.com/",
icon: ["fab", "facebook-f"],
},
{
name: "Instagram",
url: "https://www.instagram.com/",
icon: ["fab", "instagram"],
},
{
name: "Twitter",
url: "http://www.twitter.com/",
icon: ["fab", "twitter"],
},
]}
/>
</div>
);
}
【问题讨论】:
标签: javascript reactjs navigation