在链接反应路由器dom中传递对象

时间:2018-11-10 10:29:25

标签: reactjs

我想在路由器的链接中传递一个对象,但没有任何效果,您有想法吗?

<Row>
      {
        pokemonsList.map((pokemon, id) => (
          <Col md="3" className="mt-2 mb-2"
            key={id}>
            <Card>
              <CardImg top width="100%"
                src={`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${id + 1}.png`} />
              <CardBody className="bg-light">
                <CardTitle
                  className="text-center">
                  {pokemon.name}
                </CardTitle>
                <Button color="info"
                  className="btn-block text-center">
                  <Link
                    to={routes.POKEMON}
                    className="text-white">
                    add
                  </Link>

1 个答案:

答案 0 :(得分:-1)

  <Router>
    <div className="container-fluid">
      <div className="container p-0 bg-white border-right border-left">
        <Route exact path={`${routes.HOME}`} component={() => 
        <Home />} />
        <Route exact path={`${routes.POKEMONLIST}`} component={() => 
        <PokemonList />} />
        <Route exact path={`${routes.POKEMON}`} component={() => 
        <Pokemon />} />
        </div>
    </div>
  </Router>

请尝试以上语法