Открыть новую ссылку с помощью Click Card (ReactJS) - PullRequest
0 голосов
/ 15 октября 2018

Я использую карты ReactJS для своей программы

import Card from 'material-ui/Card/Card';

Я хочу перейти по ссылке, например, www.google.com, когда нажимаю на карту.Как мне это сделать?

Ответы [ 2 ]

0 голосов
/ 15 октября 2018

Используйте

<a href="https://www.google.com/">

вместо Link компонента для внешних ссылок.

0 голосов
/ 15 октября 2018
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>
...