收藏
回答

setdata如何赋值给集合中的数组?

           for(var i = 0 ;i < that.data.towsClass.length;i++){
              console.log('I第'+i)
              console.log(that.data.towsClass[i].towsName)
              console.log(that.data.listData.length)
              for(var j = 0; j < that.data.listData.length;j++){ 
                console.log('J第'+j)
                console.log(that.data.listData[j].towsName)
                console.log(that.data.towsClass[i].id)
                let a = that.data.listData[j].towsName
                let b = that.data.towsClass[i].id
                let c = that.data.towsClass[i].towsName
                console.log(a)
                console.log(b)
                console.log(c)

                if (Number(a) == Number(b)) {
                  listData[j].towsName = c
                  that.setData({
                    listData
                  })
                  console.log('更改成功')
                }
              }
            }

VM185:1 thirdScriptError

listData is not defined;at api request success callback function

ReferenceError: listData is not defined

    at success (http://127.0.0.1:46289/appservice/pages/checkoutlist/checkoutlist.js:61:19)

    at Function.o.<computed> (WAService.js:1:1116874)

    at WAService.js:1:102889

    at C (WAService.js:1:422326)

    at i.<anonymous> (WAService.js:1:741526)

    at i.emit (WAService.js:1:444906)

    at Rs (WAService.js:1:742134)

    at WAService.js:1:743355

    at WAService.js:1:455576

    at n (http://127.0.0.1:46289/appservice/__dev__/asdebug.js:1:3068)

回答关注问题邀请回答
收藏

1 个回答

  • Mr.Zhao
    Mr.Zhao
    2020-02-01

     listData is not defined 这个错误,你不知道怎么造成的吗。 看我圈住的这两个地方,listData,你定义了?let listData = that.data.listData, 你少了这一步

    2020-02-01
    有用 1
    回复 1
    • 显龙
      显龙
      2020-02-01
      我知道了,原来是自己的数组赋值没有写好,你之前回答过,谢谢你
      2020-02-01
      回复
登录 后发表内容
问题标签