• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 Vue 게시판 axios json array push 문제.

axios json array push 문제.

2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 글쓴이
  • #14852

    최형래
    참가자

    안녕하세요 json 데이터를 받아와서 기존데이터에 밀어 넣으면 다음배열 한칸에 또 다른 배열이 들어가버리는 식으로 저장되어 버립니다.

    어떻게 해야할까요?

     

    export default {
        name : 'produtList',
        data(){
            return {
                ListData : [],
                ReqPage: 1,         
            }
        } ,

    데이터 형태 :ListData
    [
        {
            "rownum": 17,
            "ProductNo": 1706,
            "ProductCode": "DI32120038_12",
            "ProductName": "1500150 레귤러트윌치노",
            "ProductPrice": 138000,
            "ProductPriceSale": 138000,
            "ProductImageUrl": "https://gant.test.com/data/ProductImages/a/2/DI32120038_12.jpg",
            "ModelImageUrl": "https://gant.test.com/data/ProductImages/model01/2/DI32120038_12.jpg"
        }

    ]

    axious 

    .then(result =>{     
                    this.ListData.push(result.data);

    >> 여기를 this.ListData = result.data;  이렇게 바꾸면 기존 화면이 정상적으로 바뀌긴 합니다.(아래로 붙는게 아니고)
                    console.log(this.ListData);
                })
                .catch(err=>{
                    console.log(err);
                })

     

     

     

    #14857

    codingapple
    키 마스터

    array 두개를 합치려면 push가 아닌 concat() 함수를 쓰면 됩니다 

2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠