【发布时间】:2019-12-11 20:31:20
【问题描述】:
在 react-native-sectioned-multi-select 中显示一个数组时遇到问题,该数组接受有孩子的数组,我想创建这样的数组,
StaffData: [ {
name: 'Users',
id: 0,
// these are the children or 'sub items'
children: [
{
name: 'Apple',
id: 10,
},
{
name: 'Strawberry',
id: 17,
},
{
name: 'kolo',
id: 13,
},
{
name: 'mo',
id: 14,
},
{
name: 'n',
id: 15,
},
{
name: 'n',
id: 16,
},
],
}]
从此 基本上我希望下面的数组有一个像上面数组一样有'id'和'name'的父级
var secondarray =
{"StaffData":
[{"id":1,"name":"Obi"},
{"id":2,"name":"Logistics"},
{"id":3,"name":"Security"},
{"id":4,"name":"Admin"},
{"id":5,"name":"Admin2"}]}
如果我做不到,如何在 react-native-sectioned-multi-select 上显示第二个数组
【问题讨论】:
-
您能分享一下您一直在使用的代码吗?
标签: javascript arrays reactjs react-native