鍍金池/ 問(wèn)答/HTML/ Cannot read property '0' of undefined 報(bào)

Cannot read property '0' of undefined 報(bào)錯(cuò)

axios請(qǐng)求到數(shù)據(jù)對(duì)數(shù)據(jù)做處理時(shí),最后的if判斷時(shí)就報(bào)錯(cuò),隱藏最后if就不報(bào)錯(cuò)了,console.log(state.alllisti.payStatus)這個(gè)也能打印出來(lái),現(xiàn)在就是不知道為什么報(bào)錯(cuò),求大神指導(dǎo)

state.allList = response.data.data
if (list === 'canReservion' && state.allList.length > 0) {
  for (let i = 0; i < state.allList.length; i++) {
    for (let j = 0; j < state.allList[i].length; j++) {
      console.log(state.allList[i][j].payStatus)
      // console.log(state.alllist[i][j].payStatus)
      if (state.alllist[i][j].payStatus === '1') {
        console.log(state.allList[i][j].payStatus)
        state.nopaynum = true
        break
      }
    }
  }
} else {
  state.nopaynum = false
}
回答
編輯回答
你的瞳

debugger 調(diào)試一下吧,看一下報(bào)錯(cuò)是哪一行的問(wèn)題,或者把 axios 回掉數(shù)據(jù)數(shù)據(jù)貼出看一下,看起來(lái)就是數(shù)組某一項(xiàng)沒(méi)有值導(dǎo)致的問(wèn)題

2018年2月4日 06:44
編輯回答
尛曖昧

已解決了,謝謝

2017年1月30日 15:26