比如说原数组返回了十个属性,你只想要两个,而且属性 名称还和以前的不一样,你就可以写如下类似写法:

          const users = result.map(item => ({
            name: item.login,
            avatarUrl: item.avatar_url,
            url: item.html_url
          }));

其中({})的写法,类似return{}这样的写法

相关文章:

  • 2021-05-01
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
  • 2021-11-08
  • 2022-12-23
  • 2021-11-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案