小编mis*_*iam的帖子

获取组件外的参数

我想检索组件外部的当前参数,并且据我所知,React Router没有提供方便的方法.

有时在0.13之前,路由器有getCurrentParams()这是我以前使用的.

现在我能想到的最好的事情是:

// Copy and past contents of PatternUtils into my project
var PatternUtils = require('<copy of PatternUtils.js>')

const { remainingPathname, paramNames, paramValues } =
   PatternUtils.matchPattern(
       "<copy of path pattern with params I am interested in>",    
   window.location.pathname);
Run Code Online (Sandbox Code Playgroud)

有没有办法用React路由器做到这一点?

react-router

8
推荐指数
1
解决办法
1229
查看次数

标签 统计

react-router ×1