Dhr*_*_04 5 reactjs react-hooks hookrouter
我是反应和反应挂钩的新手。我正在使用hookrouter包,我尝试用谷歌搜索这个问题,但没有找到太多相关信息。
我想要的是?
我正在尝试获取当前的 url 路径。对于例如对于https://example.com/users/temp,我想要得到/users/temp。
任何帮助将不胜感激。提前致谢!
我终于在github上找到了doc。
import {usePath} from 'hookrouter';
const PathLabel = () => {
const path = usePath();
return <span>Your current location: {path}</span>;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9262 次 |
| 最近记录: |