鉴于以下路由器:
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());
});
});
?
答案 0 :(得分:3)
如果我没记错的话,可以通过props.match.params