reactjs 如何使用select和option呈现项列表并添加链接以导航到每个项的id

s4n0splo  于 2022-12-26  发布在  React
关注(0)|答案(1)|浏览(133)

'

<Label >Movies:</Label>
      <Selected>
       {movie.map((item)=>{
        return<>
       <Link><Option>{item.name}</Option></Link>
        </>
       })}
      </Selected>

我试图获得列表中每个元素的ID并使用参数属性,但它说不能在内部选择中使用链接。我尝试了许多库,但我不能。

qco9c6ql

qco9c6ql1#

试试这个:

<Label >Movies:</Label>
<Selected>
         {movie.map((item)=>(<Option><Link href=`api/${item.id}`>{item.name}</Link></Option>)
       })}
</Selected>

相关问题