map 方法第一个参数不是item嘛?为什么是index

来源:3-3 使用cheerio进行数据提取

哈士奇附体

2020-06-04

map 方法第一个参数不是item嘛?为什么是index

public getJsonInfo(html:string) {
    const $ = cheerio.load(html)
    const courseItems = $('.course-item');
    console.log(courseItems)
    courseItems.map((index, element)=> {
      console.log(index, element)
    })
  }
写回答

3回答

Dell

2020-06-13

哦哦,我知道了,这是cheerio的api,它自己就是反的。

1
1
哈士奇附体
非常感谢!
2020-06-14
共1条回复

慕斯卡7269444

2021-09-14

https://github.com/cheeriojs/cheerio/wiki/Chinese-README#map-functionindex-element-

0
0

Dell

2020-06-07

我应该写错了

0
2
Dell
回复
哈士奇附体
你降级下版本,看看咱们的版本号是不是一致的,不排除库升级后,版本参数变化了
2020-06-20
共2条回复

专为小白设计的TypeScript入门课

Dell老师专为TypeScript小白打造的,全栈式教学TS入门课程

2249 学习 · 506 问题

查看课程