在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ Cannot read property '0' of undefined 報

Cannot read property '0' of undefined 報錯

axios請求到數(shù)據(jù)對數(shù)據(jù)做處理時,最后的if判斷時就報錯,隱藏最后if就不報錯了,console.log(state.alllisti.payStatus)這個也能打印出來,現(xiàn)在就是不知道為什么報錯,求大神指導(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)試一下吧,看一下報錯是哪一行的問題,或者把 axios 回掉數(shù)據(jù)數(shù)據(jù)貼出看一下,看起來就是數(shù)組某一項(xiàng)沒有值導(dǎo)致的問題

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

已解決了,謝謝

2017年1月30日 15:26