{{state.row[0]}}값은 있는데 객체 내 값에 접근 못할때

keep_going·2023년 5월 11일
0

문제해결

목록 보기
25/36
  • 문제
    {{ state.row[0] }}을 찍어보면
{ "id": 1, 
"productEngName": "Jordan 1 Mid SE ASW Black",
"productKorName": "조던1 미드 SE ASW 블랙",
"modelNumber": "DD1649-001", 
"color": "BLACK/WHITE/BLACK", 
"launchingDate": "2021-02-01", 
"launchingPrice": 139000, 
"imagePath": "https://img.soldout.co.kr/items/2021/01/20/8e65b4d3-445e-473e-b899-71155738ee2c.png/soldout/resize/1125x1125/optimize", 
"brandName": "Jordan", 
"buyWishPrice": 30000, "sellWishPrice": 250000,
"inventoryDiv": 2, 
"price": 320000 } 

이렇게 출력되는데
state.row[0].imagePath 이렇게 접근하면
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'imagePath')
오류 발생...

  • 해결
    undefined뜨는건 렌더링 문제라는걸 경험상 알고 있어서
    v-if="state.row"
    조건을 걸었는데도 오류가 남...
    알고보니
    v-if="state.row[0]"로 해줘야 됐던것.. wow~!
profile
keep going

0개의 댓글