react中利用react-router怎么实现点击图片跳转?

想实现点击Paper组件,跳转到一个新的链接,可以使用Link和Redirect,不能用a标签,会导致全局重新加载。handleVideoClick方法已经能识别出点击了哪一个Paper,但是不知道怎么写跳转的逻辑。因为不能在非render中渲染视图,所以不知道怎么做。
importReactfrom'react';
importPropTypesfrom'prop-types';
import{withStyles,createStyleSheet}from'material-ui/styles';
import{Link,Redirect}from'react-router-dom';
importPaperfrom'material-ui/Paper';
importTypographyfrom'material-ui/Typography';
importreptileImagefrom'../images/bg.jpg';
conststyleSheet=createStyleSheet('VideoList',{
card:{
maxWidth:"98%",
margin:"0auto",
},
});
classVideoListextendsReact.Component{
constructor(props){
super(props);
}
handleVideoClick(videoId,event){
event.preventDefault();
console.log(videoId);
}
render(){
constclasses=this.props.classes;
return(
className={classes.card}
style={{marginTop:10}}
onClick={this.handleVideoClick.bind(this,"10001")}
>
style={{
marginRight:10,
marginLeft:10,
}}
>
Lizard
Lizardsareawidespreadgroupofsquamatereptiles,withover
6,000species,rangingacrossallcontinentsexceptAntarctica
style={{
marginRight:10,
marginLeft:10,
}}
>
Lizard
Lizardsareawidespreadgroupofsquamatereptiles,withover
6,000species,rangingacrossallcontinentsexceptAntarctica
);
}
}
VideoList.propTypes={
classes:PropTypes.object.isRequired,
};
exportdefaultwithStyles(styleSheet)(VideoList);
凤凰求蛊
浏览 971回答 2
2回答

智慧大石

react-router里不是有个hashHistorybrowserHistory两个方法??browserHistory.push();hastHistory.push();都可以跳转啊
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript