在React Router v5中,有一个针对历史对象的侦听方法。使用这个方法,我编写了一个usePathname钩子来重新呈现路径更改上的组件。在React路由器v6中,此方法已不复存在。钩子与v5一起使用。import React from "react";
export function usePath
我使用的是React Router Dom v5,我想从localhost:3000/v3/cars的url导航到localhost:3000/cars onClick。例如:history.push('edit')将url更改为"localhost:3000/v3/cars/edit",而不是"localhost:3000/v3/edit",如何导航到不同的路径?