我想在像这样处理数据数组的同时使用像[2,4]这样的id数组进行反应选择:
[
{ value:1, label:"item1" },
{ value:2, label:"item2" },
{ value:3, label:"item3" },
{ value:4, label:"item4" },
]
我在文档中找不到如何自定义这些内容。
答案 0 :(得分:2)
您可以使用map循环为react-select创建选项。
const datas = [2,4];
datas.map((d) => {return { value: d, label: d }})