如何从子组件中访问react-router-redux URL参数?

时间:2017-05-30 15:28:35

标签: reactjs react-router react-router-redux

鉴于以下路由器:

class Welcome extends React.Component {
  constructor(props) {
    super(props);
    console.log('constructor');
    console.log(props.params);
  }
....

从'react'导入React; 从'react-redux'导入{connect};

props.params

为什么我没有在构造函数中获得const request = require('request'); const cheerio = require('cheerio'); var url = 'http://www.sylire.com/'; var customHeaderRequest = request.defaults({ headers: {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'} }) customHeaderRequest.get(url, function(err, resp, body){ $ = cheerio.load(body); links = $('a'); $(links).each(function(i, link){ console.log($(link).text()); }); });

1 个答案:

答案 0 :(得分:3)

如果我没记错的话,可以通过props.match.params

访问参数