首页 > 解决方案 > 反应:使用图像作为链接

问题描述

如何在反应中使图像可点击,我尝试了这两种方法

第一个根本不起作用

{ this.state.posts.map((post) => {
   return (  
    <div class="col-md-6 col-6 padding animate-box" data-animate-effect="fadeIn">
       <div class="fh5co_suceefh5co_height_2">
        <Link to={`/Post/${post.id}`}>
         <img src={post.image} />
        </Link>
       </div>

至于这个,我显然需要从 react-native 导入 {image} 但是当我安装 react native 时出现此错误:

错误./node_modules/react-native/index.js

react-native 模块解析失败

{ this.state.posts.map((post) => {
  return (
   <div class="col-md-6 col-6 paddding animate-box" data-animate-effect="fadeIn">
   <div class="fh5co_suceefh5co_height_2">
     <Link to={`/Post/${post.id}`}>
       <Image src={post.image} />
     </Link>
   </div>

标签: reactjs

解决方案


推荐阅读