我在程序中使用ReactJS卡
import Card from 'material-ui/Card/Card';
当我按下卡片时,我想转到一个链接,例如www.google.com。我该怎么做?
答案 0 :(得分:0)
routeTo(){
window.open('http://www.google.com'); //This will open Google in a new
}
}
<Card className={classes.card} onClick={()=>this.routeTo()}>
<CardActionArea>
<CardContent>
<Typography gutterBottom variant="h5" component="h2">
Lizard
</Typography>
<Typography component="p">
Lizards are a widespread group of squamate reptiles, with over 6,000
species, ranging across all continents except Antarctica
</Typography>
</CardContent>
</CardActionArea>
<CardActions>
<Button size="small" color="primary" onClick={() => alert("Share")}>
Share
</Button>
<Button size="small" color="primary">
Learn More
</Button>
</CardActions>
</Card>
答案 1 :(得分:0)
使用
<a href="https://www.google.com/">
代替外部链接的Link
组件。