import SmartLink from '@/components/SmartLink' import { useRouter } from 'next/router' import { useState } from 'react' export const MenuItemDrop = ({ link }) => { const [show, changeShow] = useState(false) const router = useRouter() if (!link || !link.show) { return null } const hasSubMenu = link?.subMenus?.length > 0 const selected = router.pathname === link.href || router.asPath === link.href return (
  • changeShow(true)} onMouseOut={() => changeShow(false)}> {!hasSubMenu && (
    {link?.icon && } {link?.name}
    )} {/* 包含子選單 */} {hasSubMenu && ( <>
    {link?.icon && } {link?.name} {hasSubMenu && ( )}
    {/* 下拉選單內容 */}
      {link?.subMenus?.map((sLink, index) => { return (
    • {link?.icon &&   } {sLink.title}
    • ) })}
    )}
  • ) }