#使用useHistory
import { useLocation } from 'react-router' const location = useLocation() const routerName = () => { console.log(location.pathname) return location.pathname }
当前路由为:routerName 函数返回值(location.pathname)