setdata如何赋值给集合中的数组?
发布于 8 年前 作者 jing30 7532 次浏览 来自 问答
           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 回复

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

回到顶部