这个for循环有什么问题,webstorm老师提示 dosent loop

这是this.showSocData
image.png

for (let index of this.showSocData){

        this.showSocData[index] = this.showSocData[index].value.replace('%','')*1
        return this.showSocData;
      }
已解决 悬赏分:80 - 解决时间 2021-11-27 17:27
反对 0举报 0 收藏 0

回答4

最佳
  • @

    应该是doesnt loop(不会循环)吧,你直接在for循环中return了,所以循环只会执行一次,不会遍历this.showSocData中的所有数据。

    支持 0 反对 0 举报
    2021-11-27 07:08
  • @

    for-of你定义的index直接就是每一项的值了,不是for-in循环

    支持 0 反对 0 举报
    2021-11-27 08:18
  • @
    this.showSocData[index].value

    多了.value?

    支持 0 反对 0 举报
    2021-11-27 08:42
  • @

    for-of遍历的直接是数组成员,并不是数组索引;试试for in 或者用map来实现

    支持 0 反对 0 举报
    2021-11-27 09:44