React获取当前页面路由路径

获取当前页面路由路径:

1
2
3
const urlParams = new URL(window.location.href);
const pathname = urlParams?.pathname;
console.log("pathname:", pathname);
作者

knight

发布于

2022-04-18

更新于

2022-04-18

许可协议

评论