📜  获取当前路由名称 nextjs - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:21.405000             🧑  作者: Mango

代码示例1
import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'

const menu = [
  { title: 'Home', path: '/home' },
  { title: 'Explore', path: '/explore' },
  { title: 'Notifications', path: '/notifications' },
]

const Sidebar = () => {
  const router = useRouter()

  return (
    
{menu.map((item, index) => { return ( {item.title} ) })}
) } export default Sidebar