import Link from 'next/link' import { useState } from 'react' import { useRouter } from 'next/router' import Collapse from './Collapse' export const MenuItem = ({ link }) => { const [show, changeShow] = useState(false) // const show = true // const changeShow = () => {} const router = useRouter() if (!link || !link.show) { return null } const hasSubMenu = link?.subMenus?.length > 0 const selected = (router.pathname === link.to) || (router.asPath === link.to) link.selected = true // const { group } = props const [isOpen, changeIsOpen] = useState(link?.selected) const toggleOpenSubMenu = () => { changeIsOpen(!isOpen) } console.log('link::') console.log(link) return <>
{link?.icon && }{link?.name}
{link?.subMenus?.map((sLink, index) => (
{/*
*/} {sLink.title} )) }
// return
  • changeShow(true)} onMouseOut={() => changeShow(false)} > // {hasSubMenu && //
    //
    // {link?.icon && } {link?.name} // {hasSubMenu && } //
    //
    // } // {!hasSubMenu && //
    // // {link?.icon && } {link?.name} // //
    // } // {/* 子菜单 */} // {hasSubMenu &&
      // {link?.subMenus?.map((sLink, index) => { // return
    • // // {link?.icon &&   }{sLink.title} // //
    • // })} //
    } //
  • }