【问题标题】:Display specific flastlist items with specific keys使用特定的键显示特定的 flastlist 项目
【发布时间】:2023-04-08 11:50:01
【问题描述】:

我的数据:

const DATA = [
  {
    id: "1",
    from: "Canada",
    name: "person1",
  },
  {
    id: "2",
    from: "Canada",
    name: "person2",
  },
  {
    id: "3",
    from: "France",
    name: "person3",
  }];

我需要过滤这个 flatList 并且只显示来自加拿大的人

【问题讨论】:

    标签: reactjs react-native react-native-flatlist


    【解决方案1】:

    我认为您正在寻找类似的东西:

    const result = DATA.filter(element=> element.from === "Canada")
    

    然后您可以使用您的结果以您想要的格式显示它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-22
      • 2020-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-04
      相关资源
      最近更新 更多