我正在尝试设置我的反应前端,但它不断中断,我附上了我应该看到的图像,我得到了,代码恰好是相同的,但我似乎无法弄清楚。
import React from "react";
import { HiMenuAlt4 } from "react-icons/hi";
import { AiOutlineClose } from "react-icons/ai";
import logo from "../../images/logo.png";
const NavBarItem = ({ title, classprops }) => (
<li className={`mx-4 cursor-pointer ${classprops}`}>{title}</li>
);
const Navbar = () => {
const [toggleMenu, setToggleMenu] = React.useState(false);
return (
<nav className="w-full flex md:justify-center justify-between items-center p-4">
<div className="md:flex-[0.5] flex-initial justify-center items-center">
<img src={logo} alt="logo" className="w-32 cursor-pointer" />
</div>
<ul className="text-white md:flex hidden list-none flex-row justify-between items-center flex-initial">
{["Market", "Exchange", "Tutorials", "Wallets"].map((item, index) => (
<NavBarItem key={item + index} title={item} />
))}
<li className="bg-[#2952e3] py-2 px-7 mx-4 rounded-full cursor-pointer hover:bg-[#2546bd]">
Login
</li>
</ul>
<div className="flex relative">
{!toggleMenu && (
<HiMenuAlt4 fontSize={28} className="text-white md:hidden cursor-pointer" onClick={() => setToggleMenu(true)} />
)}
{toggleMenu && (
<AiOutlineClose fontSize={28} className="text-white md:hidden cursor-pointer" onClick={() => setToggleMenu(false)} />
)}
{toggleMenu && (
<ul
className="z-10 fixed -top-0 -right-2 p-3 w-[70vw] h-screen shadow-2xl md:hidden list-none
flex flex-col justify-start items-end rounded-md blue-glassmorphism text-white animate-slide-in"
>
<li className="text-xl w-full my-2"><AiOutlineClose onClick={() => setToggleMenu(false)} /></li>
{["Market", "Exchange", "Tutorials", "Wallets"].map(
(item, index) => <NavBarItem key={item + index} title={item} classprops="my-2 text-lg" />,
)}
</ul>
)}
</div>
</nav>
);
};
export default Navbar;
你可以尝试一下 ul className 中的隐藏标签吗?
<ul className="text-white md:flex list-none flex-row justify-between items-center flex-initial">
{["Market", "Exchange", "Tutorials", "Wallets"].map((item, index) => (
<NavBarItem key={item + index} title={item} />
))}
<li className="bg-[#2952e3] py-2 px-7 mx-4 rounded-full cursor-pointer hover:bg-[#2546bd]">
Login
</li>
</ul>
哎呀,还是没能解决 如果您找到任何解决方案,请告诉我