gpt4 book ai didi

reactjs - 用图像填充 react 选择

转载 作者:行者123 更新时间:2023-12-03 13:42:16 30 4
gpt4 key购买 nike

如何传递选项来预览 select 中的图像。我选择了国家/地区,并且想预览国旗。我不知道在这种情况下如何传递“选项”对象。

    var countries = 
[
{value: 'me', label: 'Montenegro'},
{value:'rs',label: 'Serbia' }
];

<Select name={"nationality_" + passenger.passengerId}
value={passenger.nationality}
options={countries}/>

最佳答案

将国家/地区的标签更改为 html。

const options = [
{ value: 'chocolate', label: <div><img src={copyIcon} height="30px" width="30px"/>Chocolate </div> },
{ value: 'strawberry', label: 'Strawberry' },
{ value: 'vanilla', label: 'Vanilla' },
];

像这样添加,这将在选择选项中添加图像。

关于reactjs - 用图像填充 react 选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45940726/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com