📅  最后修改于: 2022-03-11 15:04:04.378000             🧑  作者: Mango
import { useLocation } from 'react-router-dom'
// Location is, for example: http://localhost:3000/users/new
// Care! MyComponent must be inside Router to work
const MyComponent = () => {
const location = useLocation()
// location.pathname is '/users/new'
return Path is: {location.pathname}
}
export default MyComponent