猿问

如何在带有本机反应的平面列表中显示对象数组中的数组列表?

如何在带有本机反应的平面列表中显示另一个数组对象中的数组数据列表?


这是下面我想在平面列表中显示的数据列表


const data = [

  {

    students: [

      {

        name: 'crystal',

        city: 'town',

        number: 1,

      },

      {

        name: 'barbra',

        city: 'street',

        number: 2,

      },

    ],

  },

];

我在下面试过这个,但没有显示


  <FlatList

        data={data.students}

        renderItem={({ item }) => {

          return (

            <View>

              <View>

                <Text style={{ fontSize: 16 }}>{item.name}</Text>

                <Text style={{ fontSize: 16 }}>{item.city}</Text>

                <Text style={{ fontSize: 16 }}>{item.number}</Text>

              </View>

            </View>

          );

        }}

      />


30秒到达战场
浏览 151回答 1
1回答

泛舟湖上清波郎朗

const data = [&nbsp; {&nbsp; &nbsp; students: [&nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; name: "crystal",&nbsp; &nbsp; &nbsp; &nbsp; city: "town",&nbsp; &nbsp; &nbsp; &nbsp; number: 1&nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; name: "barbra",&nbsp; &nbsp; &nbsp; &nbsp; city: "street",&nbsp; &nbsp; &nbsp; &nbsp; number: 2&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; ]&nbsp; }];class App extends Component {&nbsp; render() {&nbsp; &nbsp; console.log(data[0].students)&nbsp; &nbsp; return (&nbsp; &nbsp; &nbsp; <FlatList&nbsp; &nbsp; &nbsp; &nbsp; data={data[0].students}&nbsp; &nbsp; &nbsp; &nbsp; renderItem={({ item }) => {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <View>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <View>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Text style={{ fontSize: 16 }}>{item.name}{console.log(item)}</Text>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Text style={{ fontSize: 16 }}>{item.city}</Text>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Text style={{ fontSize: 16 }}>{item.number}</Text>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </View>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </View>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );&nbsp; &nbsp; &nbsp; &nbsp; }}&nbsp; &nbsp; &nbsp; />&nbsp; &nbsp; );&nbsp; }}
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答